25.05.2015, 15:46
strtok and ReturnUser are really old and slow methods for that. The best option is sscanf.
Same applies for dcmd. ZCMD and y_commands are faster methods.
And all you'd have to do is:
Same applies for dcmd. ZCMD and y_commands are faster methods.
And all you'd have to do is:
PHP код:
CMD:crimes(playerid, params[])
{
if (PlayerInfo[playerid][pSpawn] != 1) return SendClientMessage(playerid, COLOR_ERROR, "You Cannot Use This Command When You're Dead.");
if (PlayerInfo[playerid][pTeam] != TEAM_CIVILIAN) return SendClientMessage(playerid, COLOR_ERROR, "Only Civilians Can Use This Command.");
new giveplayerid;
if (isnull(params)) giveplayerid = playerid;
else if (!sscanf(params, "r", giveplayerid))
{
if (giveplayerid == INVALID_PLAYER_ID)
{
new string[23];
format(string, sizeof(string), "%d Is Not A Valid ID.", giveplayerid);
SendClientMessage(playerid, COLOR_ERROR, string);
return 1;
}
}
new string[100];
switch (PlayerInfo[giveplayerid][pWantedLevel])
{
case 0: format(string, sizeof(string), "Wated Level %d - Innocent Civilian", PlayerInfo[giveplayerid][pWantedLevel]);
case 1 .. 5: format(string, sizeof(string), "~y~Wated Level %d", PlayerInfo[giveplayerid][pWantedLevel]);
case 6 .. 10: format(string, sizeof(string), "~r~Wated Level %d", PlayerInfo[giveplayerid][pWantedLevel]);
}
if(PlayerCrimeListRowNo[giveplayerid] > 0)
{
TextDrawHideForPlayer(playerid, Menu_Title[playerid]);
TextDrawHideForPlayer(playerid, Menu_Stats[playerid]);
TextDrawHideForPlayer(playerid, Menu_End[playerid]);
for(new r = 0; r < MAX_TEXTDRAW_ROWS; r++)
{
TextDrawHideForPlayer(playerid, Menu_Column1[playerid][r]);
TextDrawHideForPlayer(playerid, Menu_Column2[playerid][r]);
}
ShowTextDrawMenu(playerid, TD_MENU_INFO,"~g~Crime History", PlayerCrimeListRowNo[giveplayerid] + 5, 0);
//ShowTextDrawMenuItems(playerid, 0, " ", " ", " ",0);
format(string, sizeof(string), "%s (%d)~n~%s", PlayerInfo[giveplayerid][pName], giveplayerid, string);
ShowTextDrawMenuItems(playerid, 0, string, " ", " ",0);
ShowTextDrawMenuItems(playerid, 1, " ", " ", " ",0);
ShowTextDrawMenuItems(playerid, 2, " ", " ", " ",0);
ShowTextDrawMenuItems(playerid, 3, " ", " ", " ",0);
//ShowTextDrawMenuItems(playerid, 3, " ", Line[0], LineEx[0],0);
ShowTextDrawMenuItems(playerid, 4, " ", PlayerCrimeList[playerid][1], " ", 0);
ShowTextDrawMenuItems(playerid, 5, " ", PlayerCrimeList[playerid][2], " ", 0);
ShowTextDrawMenuItems(playerid, 6, " ", PlayerCrimeList[playerid][3], " ", 0);
ShowTextDrawMenuItems(playerid, 7, " ", PlayerCrimeList[playerid][4], " ", 0);
ShowTextDrawMenuItems(playerid, 8, " ", PlayerCrimeList[playerid][5], " ", 0);
ShowTextDrawMenuItems(playerid, 9, " ", PlayerCrimeList[playerid][6], " ", 0);
ShowTextDrawMenuItems(playerid, 10, " ", PlayerCrimeList[playerid][7], " ", 0);
ShowTextDrawMenuItems(playerid, 11, " ", PlayerCrimeList[playerid][8], " ", 0);
ShowTextDrawMenuItems(playerid, 12, " ", PlayerCrimeList[playerid][9], " ", 0);
}
else
{
format(string, sizeof(string), "No Crimes Committed By %s (%d).", PlayerInfo[giveplayerid][pName], giveplayerid);
SendClientMessage(playerid, COLOR_ERROR, string);
}
return 1;
}