dcmd_setscore(playerid, params[])
{
new Index;
new tmp[256];
tmp = strtok(params, Index);
new tmp2[256];
tmp2 = strtok(params, Index);
new score;
new id;
id = strval(tmp);
score = strval(tmp2);
new string[100];
new pName[MAX_PLAYER_NAME];
new pNameTwo[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerName(id, pNameTwo, sizeof(pNameTwo));
if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "Usage: /setscore (ID) (Score)");
if(score == GetPlayerScore(id)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Score must be different then current score");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid player ID");
if(PlayerInfo[playerid][Admin] < 3) return SendClientMessage(playerid, COLOR_RED, "ERROR: You need to be level 3+ to use this command");
else
{
SetPlayerScore(id, score);
format(string, sizeof(string),"-| You have set %s(%d)'s score to %d |-", pNameTwo, id, score);
SendClientMessage(playerid, COLOR_AQUA, string);
format(string, sizeof(string),"-| Administrator %s(%d) has set your score to %d |-", pName, playerid, score);
SendClientMessage(id, COLOR_AQUA, string);
}
return 1;
}
Use ZCMD and SSCANF it's far less complex!
But to find your problem, put a "print()" line in between each line of code to see where it stops: pawn Код:
You will then know what line is causing the error! |
dcmd_setscore(playerid, params[])
{
new Index;
new tmp[256];
tmp = strtok(params, Index);
new tmp2[256];
tmp2 = strtok(params, Index);
new score;
new id;
id = strval(tmp);
score = strval(tmp2);
new string[100];
new pName[MAX_PLAYER_NAME];
new pNameTwo[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, sizeof(pName));
GetPlayerName(id, pNameTwo, sizeof(pNameTwo));
if(!strlen(params)) return SendClientMessage(playerid, COLOR_RED, "Usage: /setscore (ID) (Score)");
if(score == GetPlayerScore(id)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Score must be different then current score");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_RED, "ERROR: Invalid player ID");
if(PlayerInfo[playerid][Admin] < 3) return SendClientMessage(playerid, COLOR_RED, "ERROR: You need to be level 3+ to use this command");
else
{
SetPlayerScore(id, score);
print("0");
format(string, sizeof(string),"-| You have set %s(%d)'s score to %d |-", pNameTwo, id, score);
print("1");
SendClientMessage(playerid, COLOR_AQUA, string);
print("2");
format(string, sizeof(string),"-| Administrator %s(%d) has set your score to %d |-", pName, playerid, score);
print("3");
SendClientMessage(id, COLOR_AQUA, string);
}
return 1;
}
score = strval(tmp2); id = strval(tmp)
id = strval(tmp); score = strval(tmp2)