+rep for any help!
#1

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];
Reply
#2

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)
Reply
#3

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....
}
Reply
#4

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
Reply
#5

Thanks
+rep both!
Reply
#6

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;
}
Reply
#7

Then he can do also this:
PHP код:
gTeam[playerid] = dini_Int(file,"Team"); 
- Mencent
Reply


Forum Jump:


Users browsing this thread: 6 Guest(s)