error pawn cmd [AFk]
#1

Код HTML:
C:\Documents and Settings\Administrateur\Bureau\SATDM~RP V9_FINAL\Gamemodes\gm.pwn(35220) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Administrateur\Bureau\SATDM~RP V9_FINAL\Gamemodes\gm.pwn(35220) : warning 215: expression has no effect
C:\Documents and Settings\Administrateur\Bureau\SATDM~RP V9_FINAL\Gamemodes\gm.pwn(35220) : error 001: expected token: ";", but found "]"
C:\Documents and Settings\Administrateur\Bureau\SATDM~RP V9_FINAL\Gamemodes\gm.pwn(35220) : error 029: invalid expression, assumed zero
C:\Documents and Settings\Administrateur\Bureau\SATDM~RP V9_FINAL\Gamemodes\gm.pwn(35220) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
PHP код:
CMD:afk(playerid,params[])
    {
        if(
AFK[playerid] == 1)
        {
        return 
SendClientMessage(playerid,COLOR_RED,"You're Already In AFK");
        }
        new 
string[128];
        new 
PNAME[MAX_PLAYER_NAME];
        new 
vehicleid;
        
vehicleid GetPlayerVehicleID(playerid);
        
AFK[playerid] = 1;
        
SetPlayerHealth(playerid,999999999);
        
SetVehicleHealth(vehicleid,9999999999);
        
GetPlayerHealth(playerid,OldHealth);
        
GetVehicleHealth(vehicleid,OldHealth);
        
SendClientMessage(playerid,COLOR_RED,"You're Now In AFK");
        
GetPlayerName(playeridPNAMEMAX_PLAYERS);
        
format(stringsizeof(string), "%s Is Now In AFK"PNAME);
        
SendClientMessageToAll(COLOR_BLUE,string);
        
TogglePlayerControllable(playerid,0);
        return 
1;
}
CMD:back(playerid,params[])
    {
        if(
AFK[playerid] == 0)
        {
        return 
SendClientMessage(playerid,COLOR_RED,"You're Not In AFK To Use This Command");
        }
        new 
string[128];
        new 
PNAME[MAX_PLAYER_NAME];
        
AFK[playerid] = 0;
        new 
vehicleid;
        
vehicleid GetPlayerVehicleID(playerid);
        
SetPlayerHealth(playerid,OldHealth);
        
SetVehicleHealth(vehicleid,OldHealth);
        
SendClientMessage(playerid,COLOR_GREEN,"You're Back From AFK");
        
GetPlayerName(playeridPNAMEMAX_PLAYERS);
        
format(stringsizeof(string), "%s Back From AFK"PNAME);
        
SendClientMessageToAll(COLOR_ORANGE,string);
        
TogglePlayerControllable(playerid,1);
        return 
1;

Reply
#2

Which line is 35220 ?
Reply
#3

It's not causing the error, but you got setplayerhealth and getplayerhealth inverted... You should first get the players old health before you set it to 99999
Reply
#4

Quote:
Originally Posted by xVIP3Rx
Посмотреть сообщение
Which line is 35220 ?
line : if(AFK[playerid] == 1)
Reply
#5

You'll have to change some variable to new ones
pawn Код:
new bool:AFK[MAX_PLAYERS];
new Float:OldHealth[MAX_PLAYERS];
new Float:OldVehicleHealth[MAX_VEHICLES];

CMD:afk(playerid,params[])
{
    if(AFK[playerid]) return SendClientMessage(playerid,COLOR_RED,"You're Already In AFK");
    AFK[playerid] = true;

    GetPlayerHealth(playerid,OldHealth[playerid]);
    SetPlayerHealth(playerid,999999999);
   
    new vehicleid = GetPlayerVehicleID(playerid);
    GetVehicleHealth(vehicleid,OldVehicleHealth[vehicleid]);
    SetVehicleHealth(vehicleid,9999999999);

    new string[128], PNAME[MAX_PLAYER_NAME];
    GetPlayerName(playerid, PNAME, MAX_PLAYERS);
       
    format(string, sizeof(string), "%s Is Now In AFK", PNAME);
    SendClientMessageToAll(COLOR_BLUE,string);
    TogglePlayerControllable(playerid,0);
   
    return SendClientMessage(playerid,COLOR_RED,"You're Now AFK");
}

CMD:back(playerid,params[])
{
    if(!AFK[playerid])return SendClientMessage(playerid,COLOR_RED,"You're Not In AFK To Use This Command");
    AFK[playerid] = false;
   
    SetPlayerHealth(playerid, OldHealth[playerid]);
    SetVehicleHealth(GetPlayerVehicleID(playerid), OldVehicleHealth[GetPlayerVehicleID(playerid)]);
   
    new string[128], PNAME[MAX_PLAYER_NAME];
    GetPlayerName(playerid, PNAME, MAX_PLAYERS);

    format(string, sizeof(string), "%s Back From AFK", PNAME);
    SendClientMessageToAll(COLOR_ORANGE,string);
    TogglePlayerControllable(playerid,1);
    return SendClientMessage(playerid,COLOR_GREEN,"You're Back From AFK");
}
Reply
#6

some Error line
if(AFK[playerid]) return SendClientMessage(playerid,COLOR_RED,"You're Already In AFK");

Quote:

C:\Documents and Settings\Administrateur\Bureau\SATDM~RP V9_FINAL\Gamemodes\gm.pwn(3499 : error 029: invalid expression, assumed zero
C:\Documents and Settings\Administrateur\Bureau\SATDM~RP V9_FINAL\Gamemodes\gm.pwn(3499 : warning 215: expression has no effect
C:\Documents and Settings\Administrateur\Bureau\SATDM~RP V9_FINAL\Gamemodes\gm.pwn(3499 : error 001: expected token: ";", but found "]"
C:\Documents and Settings\Administrateur\Bureau\SATDM~RP V9_FINAL\Gamemodes\gm.pwn(3499 : error 029: invalid expression, assumed zero
C:\Documents and Settings\Administrateur\Bureau\SATDM~RP V9_FINAL\Gamemodes\gm.pwn(3499 : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


4 Errors.

Reply
#7

are you sure you replaced "new AFK;" with "new bool:AFK[MAX_PLAYERS];" ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)