Cops And Robbers FS 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: Cops And Robbers FS Help ! (
/showthread.php?tid=476172)
Cops And Robbers FS Help ! -
iAnonymous - 16.11.2013
I tried to compile an FS and got few errors ..
I fixed few errors but these seems to be impossible ..
I hope you guys will help me with this !
Code:
dcmd_setrank(playerid,params[])
{
if((gTeam[playerid] == 8) || (IsPlayerAdmin(playerid)))
{
if((CopDuty[playerid] == 1) || (IsPlayerAdmin(playerid)))
{
new tmp [256];
new tmp2[256];
new Index;
tmp = strtok(params,Index);
tmp2 = strtok(params,Index);
if(!strlen(params))
{
return SendClientMessage(playerid,RED,"Usage: /setrank [Player Id][Rank 1-8]");
}
new player1, rank, playername[MAX_PLAYER_NAME], copname[MAX_PLAYER_NAME], string[128];
player1 = strval(tmp);
if(!strlen(tmp2)) return SendClientMessage(playerid,RED,"Usage: /setrank [Player Id][Rank 1-8]");
rank = strval(tmp2);
if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID)
{
if((gTeam[player1] <= 8) && (gTeam[player1] > 0))
{
if(rank > 8 || rank < 1)
return SendClientMessage(playerid,RED,"ERROR: Invalid rank [1-8]");
if(rank == gTeam[player1]) return SendClientMessage(playerid,RED,"ERROR: Player is already this rank");
GetPlayerName(player1, playername, sizeof(playername));
GetPlayerName(playerid, copname, sizeof(copname));
gTeam[player1] = rank;
new Rank[64];
if(gTeam[player1] == 1) { Rank = "Police Officer"; }
else if(gTeam[player1] == 2) { Rank = "Investigator"; }
else if(gTeam[player1] == 3) { Rank = "Sergeant"; }
else if(gTeam[player1] == 4) { Rank = "Lieutenant"; }
else if(gTeam[player1] == 5) { Rank = "Major"; }
else if(gTeam[player1] == 6) { Rank = "Captain"; }
else if(gTeam[player1] == 7) { Rank = "Commander"; }
else if(gTeam[player1] == 8) { Rank = "Commissioner"; }
if(rank > 0 && rank < 9)
format(string,sizeof(string),"Police Radio: Commissioner %s has set %s's rank to %i [%s]",copname, playername, rank, Rank);
TeamChat(string);
return PlayerPlaySound(player1,1057,0.0,0.0,0.0);
}
else return SendClientMessage(playerid, RED, "ERROR: This player is not in the Police Team!");
}
else return SendClientMessage(playerid, RED, "ERROR: Player not found!");
}
else return SendClientMessage(playerid, RED, "ERROR: You have to be on cop duty!");
}
else return SendClientMessage(playerid, RED, "ERROR: You need to be a Police Commissioner to use this command");
}
Code:
C:\Users\Asad\Desktop\SA-MP\filterscripts\Cop.pwn(278) : error 033: array must be indexed (variable "tmp")
C:\Users\Asad\Desktop\SA-MP\filterscripts\Cop.pwn(279) : error 033: array must be indexed (variable "tmp2")
* Line 278-279 are highlighted in RED color .
Re: Cops And Robbers FS Help ! -
Vince - 16.11.2013
Means that your strtok function is incorrect. However, I recommend switching over to sscanf altogether.
Re: Cops And Robbers FS Help ! -
iAnonymous - 17.11.2013
Any way to correct it ?