31.01.2010, 23:59
Change OnPlayerUpdate, that's already a callback being called by SA-MP. Make it something like OnPlayerSave.
Do the print test to see where in OnPlayerLogin it fails.
Example of Print Test:
Let's say this is your code
And for some reason when you join it doesn't say the message you want it to, so we're going to place print functions through out the code
Now when you run the script the log will show how far 'print test' gets to.
In this example the log will only show this
So that means something is wrong with the line immediately following it
So now you know where the error lies, it's up to you to find what's wrong with it!
In this case, sizeof(tmp) is 128, which is far too large to be used in the GetPlayerName function which causes a script hault
This test can be converted to check what a variable equals before and after a function (like say, PlayerInfo[playerid][cash])
Do the print test to see where in OnPlayerLogin it fails.
Example of Print Test:
Let's say this is your code
pawn Код:
public OnPlayerConnect(playerid)
{
new tmp[128];
GetPlayerName(playerid,tmp,sizeof(tmp));
if(!strcmp(tmp,"Joe_Staff",false))
{
SendClientMessageToAll(0xFF0000FF,"All hail! Your lord has cometh!");
}
return 1;
}
pawn Код:
public OnPlayerConnect(playerid)
{
new tmp[128];
print("print test 1");
GetPlayerName(playerid,tmp,sizeof(tmp));
print("print test 2");
if(!strcmp(tmp,"Joe_Staff",false))
{
print("print test 3");
SendClientMessageToAll(0xFF0000FF,"All hail! Your lord has cometh!");
print("print test 4");
}
print("print test 5");
return 1;
}
In this example the log will only show this
Код:
print test 1
pawn Код:
GetPlayerName(playerid,tmp,sizeof(tmp));
In this case, sizeof(tmp) is 128, which is far too large to be used in the GetPlayerName function which causes a script hault
This test can be converted to check what a variable equals before and after a function (like say, PlayerInfo[playerid][cash])