Forum

> > CS2D > Scripts > Save Image
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Save Image

5 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Save Image

_Vava_
User Off Offline

Zitieren
Hello, everyone
I'm making a new RolePlay Script, and now i'm at Car system i want to save Car's in a file.
1
2
3
Car ID = 0 for player "X"
Car ID = 1 for "Name of the player or USGN who buy the car"
Car ID = 2 for "Name of the player or USGN who buy the car

so my question is ,How to create an image and give it a specific ID, which will be saved in a file at the same time with the name of the person.

I wont also to set the Image like a Wall so that other player and other Car's can't go through it.

I tried but unfortunately I am a beginner in LUA, can some one give me a key how to do it, or simply give me the code to advance in my script?
1× editiert, zuletzt 23.07.18 22:18:42

alt Re: Save Image

Bowlinghead
User Off Offline

Zitieren
You gotta start to think in arrays.
1
2
3
4
5
6
7
8
9
playerCars = {}

function addCar(carid, playerid)
	playerCars[playerid] = carid
end

function getCar(playerid)
	return playerCars[playerid]
end
There are good save/load scripts in the archive, you better take a look how they handle the player data.

The name of a person is not a good idea though, cuz the playerid/ usgnid is unique and easier to save.

alt Re: Save Image

_Vava_
User Off Offline

Zitieren
I managed to save each ID of a car with the USGN of a player

1
2
3
local file = io.open ("sys/lua/test/"..playerCars[id]..".txt", "w+")
file:write (x.. " "..y.." " .. player (id, "usgn"))
file:close ()

(X and Y is player(id,"x") and player(id,"y").... i saved them for another idea)


I have another idea is that it is possible to save the cars spawn even if the player disconnected

or if i reboot server, or something like that
4× editiert, zuletzt 24.07.18 12:11:32

alt Re: Save Image

Devil-Thanh
GAME BANNED Off Offline

Zitieren
Firstly, remove the car remove function when a player disconnected.
Then you need a car autoupdate function per minute and add load function when the server starts.


Remember to make cars separate to players. I mean cars will contain owner usgnid, not players hold car id

alt Re: Save Image

_Vava_
User Off Offline

Zitieren
@user Devil-Thanh:
I didn't understand you when you said Remove the car remove function
And for the car load function i done it, but witch hook do i need to use?

alt Re: Save Image

Devil-Thanh
GAME BANNED Off Offline

Zitieren
Here is the machenics:
• Create Cars array to hold car object
• Create cars contains: owner usgnid, x, y, img id, fuel, bla bla..
• Create cars load function and trigger it when server start.
• Create cars save function which will save cars stats and trigger it every minute for auto save and trigger it right before you CLOSE the server.
• Spawn or teleport the car when players call it. Dont remove it!
> So when a player disconnects his car will still there.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht