+rep for any 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: +rep for any help! (
/showthread.php?tid=582239)
+rep for any help! -
ironmen - 19.07.2015
Hey!
I was making saving system for gTeam its saving but not loading well!
like if it saved Police officer it loads another thing!
like if i get in the game again after save and want to get in team vehicle i cant!!
please help me!
Thanks for any help!
+rep for any help!
This is my loading code OnPlayerconnect:
Код:
SetPlayergTeam(playerid, dini_Int(file, "Team"));
My SetPlayergTeam stock:
Код:
stock SetPlayergTeam(playerid, teamid)
{
if(teamid == 1)
{
gTeam[playerid] = CIVILIAN;
}
if(teamid == 2)
{
gTeam[playerid] = POLICE;
}
if(teamid == 3)
{
gTeam[playerid] = PSD;
}
if(teamid == 4)
{
gTeam[playerid] = MECHANIC;
}
if(teamid == 5)
{
gTeam[playerid] = DOCK;
}
if(teamid == 6)
{
gTeam[playerid] = HITMAN;
}
if(teamid == 7)
{
gTeam[playerid] = MEDIC;
}
if(teamid == 8)
{
gTeam[playerid] = PILOT;
}
if(teamid == 9)
{
gTeam[playerid] = PILOT;
}
if(teamid == 10)
{
gTeam[playerid] = FIRE;
}
return gTeam[playerid];
Re: +rep for any help! -
mirou123 - 19.07.2015
I never used dini before but make sure you are opening the right file and make sure "Team" has the correct case (not sure if it's case sensitive or not)
Re: +rep for any help! -
Beckett - 19.07.2015
Well, not an answer to your dini question but if you use 'switch' statement instead of 'if' in your stock that'll be way faster though.
pawn Код:
if(team == 1)
if(team == 2)
//etc..
Could be:
pawn Код:
switch(team)
{
case 0: { var = ? }
case 1: { var = ? }
case 2: { var = ? }
//And so on....
}
AW: +rep for any help! -
Mencent - 19.07.2015
Hello!
Can you send us more code of OnPlayerConnect. Maybe the "file"?
Well, this is a better construction to set the teamid:
PHP код:
stock SetPlayergTeam(playerid,teamid)
{
switch(teamid)
{
case 1:gTeam[playerid] = CIVILIAN;
case 2:gTeam[playerid] = POLICE;
case 3:gTeam[playerid] = PSD;
case 4:gTeam[playerid] = MECHANIC;
case 5:gTeam[playerid] = DOCK;
case 6:gTeam[playerid] = HITMAN;
case 7:gTeam[playerid] = MEDIC;
case 8:gTeam[playerid] = PILOT;
case 9:gTeam[playerid] = PILOT;
case 10:gTeam[playerid] = FIRE;
}
return gTeam[playerid];
}
- Mencent
Re: +rep for any help! -
ironmen - 19.07.2015
Thanks
+rep both!
Re: +rep for any help! -
mirou123 - 19.07.2015
Actually if you post your #define's of CIVILIAN, POLICE etc... Your code can potentially become as simple as this
Код:
stock SetPlayergTeam(playerid,teamid)
{
gTeam[playerid] = teamid;
}
AW: +rep for any help! -
Mencent - 19.07.2015
Then he can do also this:
PHP код:
gTeam[playerid] = dini_Int(file,"Team");
- Mencent