SA-MP Forums Archive
Police System Errors - 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: Police System Errors (/showthread.php?tid=442728)



Police System Errors - kokoshkata - 08.06.2013

SOLVED!


Re: Police System Errors - Chadi - 08.06.2013

hello so it's very easy

PHP код:
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[30]  = strtok(params,Index);
            
tmp2[30] = strtok(params,Index);
            if(!
strlen(params))
            {
                return 
SendClientMessage(playerid,RED,"Usage: /setrank [Player Id][Rank 1-8]");
            }
               new 
player1rankplayername[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 || 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(player1playernamesizeof(playername));
                    
GetPlayerName(playeridcopnamesizeof(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 && rank 9)
                    
format(string,sizeof(string),"Police Radio: Commissioner %s has set %s's rank to %i [%s]",copnameplayernamerankRank);
                    
TeamChat(string);
                    return 
PlayerPlaySound(player1,1057,0.0,0.0,0.0);
                }
                else return 
SendClientMessage(playeridRED"ERROR: This player is not in the Police Team!");
            }
            else return 
SendClientMessage(playeridRED"ERROR: Player not found!");
        }
        else return 
SendClientMessage(playeridRED"ERROR: You have to be on cop duty!");
    }
    else return 
SendClientMessage(playeridRED"ERROR: You need to be a Police Commissioner to use this command");

PHP код:
dcmd_su(playeridparams[])
{
    if((
gTeam[playerid] <= 8) && (gTeam[playerid] > 0))
    {
        if((
gTeam[playerid] > 2) && ((gTeam[playerid] <= 8) && (gTeam[playerid] > 0)))
        {
            if(
CopDuty[playerid] == 1)
            {
                new
                    
player1,
                    
gWantedLevel,
                    
string[128],
                    
copname[MAX_PLAYER_NAME],
                    
playername[MAX_PLAYER_NAME],
                    
tmp [256],
                    
tmp2 [256],
                    
Index
                
;
                
tmp[30]  = strtok(params,Index);
                
tmp2[30] = strtok(params,Index);
                if(!
strlen(params)) return SendClientMessage(playeridRED"USAGE: /su [Player Id][Reason]");
                if(!
strlen(tmp2)) return SendClientMessage(playeridRED"ERROR: Reason unspecified!");
                
GetPlayerName(playeridcopnamesizeof(copname));
                
GetPlayerName(player1playernamesizeof(playername));
                
player1 strval(tmp);
                
format(stringsizeof(string), "Officer %s has suspected %s. [Reason: %s]"copnameplayernameparams[2]);
                
SendClientMessageToAll(COP_COLORstring);
                
Info[playerid][Suspected_Players]++;
                
gWantedLevel GetPlayerWantedLevel(player1);
                return 
SetPlayerWantedLevel(player1gWantedLevel 1);
            }
            else return 
SendClientMessage(playeridRED"ERROR: You have to be on cop duty!");
        }
        else return 
SendClientMessage(playeridRED"ERROR: Only Ranks 3 and higher can use the /su command!");
    }
    else return 
SendClientMessage(playeridRED"ERROR: You have to be a Cop to use this command!");




Re: Police System Errors - kokoshkata - 08.06.2013

Thanks it works! +Rep


Re: Police System Errors - kokoshkata - 09.06.2013

I'm bumping this with another issue, whenever I try to /setrank [PlayerID] [1-8] the command pops again and again, basically it does not work! If anyone is able to look trough the command and fix It, I'd be very thankful and REP him!

Thanks in advance!


Re: Police System Errors - Aly - 09.06.2013

Replace:
pawn Код:
return PlayerPlaySound(player1,1057,0.0,0.0,0.0);
with
pawn Код:
PlayerPlaySound(player1,1057,0.0,0.0,0.0);
return 1;



Re: Police System Errors - kokoshkata - 09.06.2013

REMOVED.