PLease help with this errors.
#1

Code:
PHP код:
dcmd_arrest(playerid,params[])
{
    new 
randomspawn random(6);
    new 
string[128];
    new 
ID;
    if(
sscanf(params"u"ID))
    {
        
SendClientMessage(playerid,COLOR_ERROR,"Use: /arrest (Player Name/ID)");
        return 
1;
    }
    if(
IsSpawned[playerid] != 1)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You must be alive and spawned in order to be able to use this command.");
        return 
1;
    }
    if(
gTeam[playerid] != TEAM_COP && gTeam[playerid] != TEAM_ARMY && gTeam[playerid] != TEAM_CIA && gTeam[playerid] != TEAM_FBI)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"Only law enforcement can arrest wanted suspects.");
        return 
1;
    }
    if(!
IsPlayerConnected(ID))
    {
        
format(string,sizeof(string),"Player is not connected. You cannot arrest him.",ID);
        
SendClientMessage(playerid,COLOR_ERROR,string);
        return 
1;
    }
      if(
GetDistanceBetweenPlayers(playerid,ID) > 4)
    {
        
format(string,sizeof(string),"%s (%d) is too far away. You cannot reach him to arrest him.",PlayerName(ID),ID);
        
SendClientMessage(playerid,COLOR_ERROR,string);
        return 
1;
    }
    if(
GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You cannot arrest a suspect while you are in a vehicle. Exit the vehicle first.");
        return 
1;
    }
    if(
GetPlayerState(ID) == PLAYER_STATE_DRIVER || GetPlayerState(ID) == PLAYER_STATE_PASSENGER)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You cannot arrest a suspect while he is in a vehicle.");
        return 
1;
    }
    if(
playerid == ID)
    {
        
SendClientMessage(playerid,COLOR_ERROR,"You cannot arrest yourself.");
        return 
1;
    }
     if(
IsSpawned[ID] != 1)
    {
        
format(string,sizeof(string),"%s (%d) is not spawned.",PlayerName(ID),ID);
        
SendClientMessage(playerid,COLOR_ERROR,string);
        return 
1;
    }
    if(
GetPlayerWantedLevel(ID) < 4)
    {
        
format(string,sizeof(string),"%s (%d)'s wanted level is too low. You cannot jail him. Use /ticket (Player ID).",PlayerName(ID),ID);
        
SendClientMessage(playerid,COLOR_ERROR,string);
        return 
1;
    }
    if(
GetDistanceBetweenPlayers(playerid,ID) <= 4)
    {
        
format(string,sizeof(string),"You have been arrested by %s (%d)",PlayerName(playerid),playerid);
        
SendClientMessage(ID,COLOR_LIGHTBLUE,string);
        
//Give the Police Officer Reward
        
IncreasePlayerScore(playerid,2);
        
//Show the jail TextDraw for suspect
        
TextDrawShowForPlayer(ID,JailTimer[ID]);
        
//Others
        
ResetPlayerWeapons(ID);
        
//Send the suspect to jail
        
if(GetPlayerWantedLevel(ID) == 4)
        {
            
format(string,sizeof(string),"%s (%d) has been arrested by %s (%d)",PlayerName(ID),ID,PlayerName(playerid),playerid);
            
SendClientMessageToAll(COLOR_LIGHTBLUE,string);
            
//Give the police officer reward
            
format(string,sizeof(string),"You have recieved $1000 for arresting %s (%d).",PlayerName(ID),ID);
            
SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
            
GivePlayerMoney(playerid,1000);
            
JailTime[ID] =60;
            
TotalJailTime[ID] =60;
            if(
CITY_LOS_SANTOS == gPlayerCitySelection[playerid])
            {
                
SetPlayerInterior(ID,6);
                switch(
randomspawn)
                {
                    case 
0SetPlayerPos(playerid264.29998779297821000.5);
                    case 
1SetPlayerPos(playerid264.2999877929777.51000.5);
                    case 
2SetPlayerPos(playerid264.2999877929786.5999984741211000.5);
                }
            }
            else if(
CITY_SAN_FIERRO == gPlayerCitySelection[playerid])
            {
                
SetPlayerInterior(ID,10);
                switch(
randomspawn)
                {
                    case 
0SetPlayerPos(playerid223.30000305176108.40000152588998.40002441406);
                    case 
1SetPlayerPos(playerid219.30000305176108.40000152588998.40002441406);
                    case 
2SetPlayerPos(playerid215.30000305176108.40000152588998.40002441406);
                    case 
3SetPlayerPos(playerid227.39999389648108.30000305176998.40002441406);
                }
            }
            else if(
CITY_LAS_VENTURAS == gPlayerCitySelection[playerid])
            {
                
SetPlayerInterior(ID,3);
                switch(
randomspawn)
                {
                    case 
0SetPlayerPos(playerid194.19999694824162.100006103521002.4000244141);
                    case 
1SetPlayerPos(playerid189.89999389648162.100006103521002.4000244141);
                    case 
2SetPlayerPos(playerid198.399993896481621002.4000244141);
                    case 
3SetPlayerPos(playerid193.39999389648174.699996948241002.4000244141);
                    case 
4SetPlayerPos(playerid189174.800003051761002.4000244141);
                    case 
5SetPlayerPos(playerid197.69999694824174.699996948241002.4000244141);
                }
            }
            
TogglePlayerControllable(ID,1);
            
SetPlayerWantedLevel(ID,0);
            
SetPlayerToTeamColour(ID);
            return 
1;
        }
        if(
GetPlayerWantedLevel(ID) == 5)
        {
            
format(string,sizeof(string),"%s (%d) has been arrested by %s (%d)",PlayerName(ID),ID,PlayerName(playerid),playerid);
            
SendClientMessageToAll(COLOR_LIGHTBLUE,string);
            
//Give the police officer reward
            
format(string,sizeof(string),"You have recieved $3000 for arresting %s (%d).",PlayerName(ID),ID);
            
SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
            
GivePlayerMoney(playerid,3000);
            
JailTime[ID] =180;
            
TotalJailTime[ID] =180;
            if(
CITY_LOS_SANTOS == gPlayerCitySelection[playerid])
            {
                
SetPlayerInterior(ID,6);
                switch(
randomspawn)
                {
                    case 
0SetPlayerPos(playerid264.29998779297821000.5);
                    case 
1SetPlayerPos(playerid264.2999877929777.51000.5);
                    case 
2SetPlayerPos(playerid264.2999877929786.5999984741211000.5);
                }
            }
            else if(
CITY_SAN_FIERRO == gPlayerCitySelection[playerid])
            {
                
SetPlayerInterior(ID,10);
                switch(
randomspawn)
                {
                    case 
0SetPlayerPos(playerid223.30000305176108.40000152588998.40002441406);
                    case 
1SetPlayerPos(playerid219.30000305176108.40000152588998.40002441406);
                    case 
2SetPlayerPos(playerid215.30000305176108.40000152588998.40002441406);
                    case 
3SetPlayerPos(playerid227.39999389648108.30000305176998.40002441406);
                }
            }
            else if(
CITY_LAS_VENTURAS == gPlayerCitySelection[playerid])
            {
                
SetPlayerInterior(ID,3);
                switch(
randomspawn)
                {
                    case 
0SetPlayerPos(playerid194.19999694824162.100006103521002.4000244141);
                    case 
1SetPlayerPos(playerid189.89999389648162.100006103521002.4000244141);
                    case 
2SetPlayerPos(playerid198.399993896481621002.4000244141);
                    case 
3SetPlayerPos(playerid193.39999389648174.699996948241002.4000244141);
                    case 
4SetPlayerPos(playerid189174.800003051761002.4000244141);
                    case 
5SetPlayerPos(playerid197.69999694824174.699996948241002.4000244141);
                }
            }
            
TogglePlayerControllable(ID,1);
            
SetPlayerWantedLevel(ID,0);
            
SetPlayerToTeamColour(ID);
            return 
1;
        }
        if(
GetPlayerWantedLevel(ID) == 6)
        {
            
format(string,sizeof(string),"%s (%d) has been arrested by %s (%d)",PlayerName(ID),ID,PlayerName(playerid),playerid);
            
SendClientMessageToAll(COLOR_LIGHTBLUE,string);
            
//Give the police officer reward
            
format(string,sizeof(string),"You have recieved $5000 for arresting %s (%d).",PlayerName(ID),ID);
            
SendClientMessage(playerid,COLOR_LIGHTBLUE,string);
            
GivePlayerMoney(playerid,5000);
            
JailTime[ID] =240;
            
TotalJailTime[ID] =240;
            if(
CITY_LOS_SANTOS == gPlayerCitySelection[playerid])
            {
                
SetPlayerInterior(ID,6);
                switch(
randomspawn)
                {
                    case 
0SetPlayerPos(playerid264.29998779297821000.5);
                    case 
1SetPlayerPos(playerid264.2999877929777.51000.5);
                    case 
2SetPlayerPos(playerid264.2999877929786.5999984741211000.5);
                }
            }
            else if(
CITY_SAN_FIERRO == gPlayerCitySelection[playerid])
            {
                
SetPlayerInterior(ID,10);
                switch(
randomspawn)
                {
                    case 
0SetPlayerPos(playerid223.30000305176108.40000152588998.40002441406);
                    case 
1SetPlayerPos(playerid219.30000305176108.40000152588998.40002441406);
                    case 
2SetPlayerPos(playerid215.30000305176108.40000152588998.40002441406);
                    case 
3SetPlayerPos(playerid227.39999389648108.30000305176998.40002441406);
                }
            }
            else if(
CITY_LAS_VENTURAS == gPlayerCitySelection[playerid])
            {
                
SetPlayerInterior(ID,3);
                switch(
randomspawn)
                {
                    case 
0SetPlayerPos(playerid194.19999694824162.100006103521002.4000244141);
                    case 
1SetPlayerPos(playerid189.89999389648162.100006103521002.4000244141);
                    case 
2SetPlayerPos(playerid198.399993896481621002.4000244141);
                    case 
3SetPlayerPos(playerid193.39999389648174.699996948241002.4000244141);
                    case 
4SetPlayerPos(playerid189174.800003051761002.4000244141);
                    case 
5SetPlayerPos(playerid197.69999694824174.699996948241002.4000244141);
                }
            }
            
TogglePlayerControllable(ID,1);
            
SetPlayerWantedLevel(ID,0);
            
SetPlayerToTeamColour(ID);
            return 
1;
        }
        return 
1;
    }
    return 
1;

Error:
PHP код:
(2026) : error 012invalid function callnot a valid address
(2026) : warning 215expression has no effect
(2026) : error 001expected token";"but found ")"
(2026) : error 029invalid expressionassumed zero
(2026) : fatal error 107too many error messages on one line 
Line 2026:
PHP код:
format(string,sizeof(string),"%s (%d) is too far away. You cannot reach him to arrest him.",PlayerName(ID),ID); 
Reply
#2

try this:
pawn Код:
format(string,sizeof(string)),"%s (%d) is too far away. You cannot reach him to arrest him.",PlayerName(ID),ID);
Reply
#3

Quote:
Originally Posted by niels44
Посмотреть сообщение
try this:
pawn Код:
format(string,sizeof(string)),"%s (%d) is too far away. You cannot reach him to arrest him.",PlayerName(ID),ID);
It will gives you error.
pawn Код:
number of arguments does not match definition
it seems good, I can't understand why it happens
Reply
#4

hmm then i cant help either i am afraid...
Reply
#5

There's an extra parenthesis after the closing sizeof(string), maybe that's why. At least at the one dwayne quoted


EDIT: What does PlayerName(playerid) look like?
Reply
#6

Delete
Reply
#7

Quote:
Originally Posted by Roperr
Посмотреть сообщение
Please post the line 2026.
I already post it...
Reply
#8

Show us how you defined
pawn Код:
PlayerName(ID)
Since the format code itself looks good to me it must be in one of the params you put into the string.
Reply
#9

Quote:
Originally Posted by Drebin
Посмотреть сообщение
Show us how you defined
pawn Код:
PlayerName(ID)
Since the format code itself looks good to me it must be in one of the params you put into the string.
This?

PHP код:
new PlayerName[MAX_PLAYER_NAME]; 
Reply
#10

Or you don't know how to use GetPlayerName, or there is a function missing.


pawn Код:
if(GetDistanceBetweenPlayers(playerid,ID) > 4)
{
    new PlayerName[MAX_PLAYER_NAME];
    GetPlayerName(ID, PlayerName, sizeof(PlayerName));
    format(string,sizeof(string),"%s (%d) is too far away. You cannot reach him to arrest him.",PlayerName,ID);
    SendClientMessage(playerid,COLOR_ERROR,string);
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)