SA-MP Forums Archive
Save/reload help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Save/reload help (/showthread.php?tid=625938)



Save/reload help - silverms - 08.01.2017

So I recently ask help so much for my event system and I still have 1 more problem to solve so what I need is when player join and event it save his skin color money and weapons and when he leave event with the cmd it load them back for him so he don't lose or any thing get changed can you tell me how to do this like lets say there is cmd:
CMD:event(playerid, params[])
{
here the code to save them
}
CMD:leaveevent(playerid, params[])
{
here the code to load them back fro hom
}
Ik I am asking a lot today but this the last problem I have in the event system so please help me.


Re: Save/reload help - BiosMarcel - 08.01.2017

This section is for help on problems, not for giving you code, also what you are trying to achieve is not that hard and possible by using variables, getter methods and setter methods.

here is an example:

PHP код:
new skin[MAX_PLAYERS];
CMD:event(playeridparams[])
{
    
skin[playerid] = GetPlayerSkin(playerid);
}
CMD:leaveevent(playeridparams[])
{
    
SetPlayerSkin(playeridskin[playerid]);

If you need information on how to do that with weapons (little harder), ****** it / search the forum


Re: Save/reload help - saffierr - 08.01.2017

Oh my God, I typed everything on my phone but per accidentally deleted it, Ill help you later, be patient.


Re: Save/reload help - silverms - 08.01.2017

ok I plz help as fast as you can


Re: Save/reload help - BiosMarcel - 08.01.2017

Quote:
Originally Posted by silverms
Посмотреть сообщение
ok I plz help as fast as you can
the information i gave u is enough


Re: Save/reload help - silverms - 08.01.2017

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
the information i gave u is enough
I tested urs and didn't work the player didn't get back his skin.


Re: Save/reload help - mongi - 08.01.2017

if u are using Dini Data base u can just write a new line and store the player skin id in it (Example: "pskin=0") and when he left the event just get it back, set the skin and remove the line.


Re: Save/reload help - silverms - 08.01.2017

Quote:
Originally Posted by mongi
Посмотреть сообщение
if u are using Dini Data base u can just write a new line and store the player skin id in it (Example: "pskin=0") and when he left the event just get it back, set the skin and remove the line.
thanks for the idea ur brilliant !


Re: Save/reload help - BiosMarcel - 08.01.2017

Quote:
Originally Posted by silverms
Посмотреть сообщение
thanks for the idea ur brilliant !
Terrible idea, but ok ...


Re: Save/reload help - saffierr - 08.01.2017

The code marcel provided, should be enough, as it is exactly the same with skins.
Anyway, here you go:

Somewhere outside a function
PHP код:
new eMoney[MAX_PLAYERS], eSkin[MAX_PLAYERS], eColor[MAX_PLAYERS]; 
In the /event cmd:
PHP код:
eMoney[playerid] = GetPlayerMoney(playerid);
eSkin[playerid] = GetPlayerSkin(playerid);
eColor[playerid] = GetPlayerColor(playerid); 
in your leaveevent:
PHP код:
GivePlayerMoney(playerideMoney[playerid]);
SetPlayerSkin(playerideSkin[playerid]);
SetPlayerColor(playerideColor[playerid]); 
For the weapons, it requires a little more code, but this should work.