SA-MP Forums Archive
command problem with id 0 - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: command problem with id 0 (/showthread.php?tid=271288)



command problem with id 0 - MWhite_005 - 23.07.2011

the command im trying to excute isnt working for id 0 (Cannot Fishslap yourself)

for(new i = 0; i < MAX_PLAYERS; i++)


Re: command problem with id 0 - Kush - 23.07.2011

Code please?


Re: command problem with id 0 - sansko - 23.07.2011

try foreach


Re: command problem with id 0 - MWhite_005 - 23.07.2011

if(strcmp(cmd, "/fishslap", true) == 0)
for(new i = 0; i < MAX_PLAYERS; i++)
{
tmp = strtok(cmdtext, idx);
if(gTeam[playerid] == CIVILIAN || gTeam[playerid] == GAZA)
{
if(playerid != strval(tmp))
{

if(GetDistanceBetweenPlayers(playerid, strval(tmp)) <= 4)

{
if(IsPlayerSpawned(playerid))
{
if(IsPlayerSpawned(strval(tmp)))
{
if(!IsPlayerInAnyVehicle(playerid))
{
if(!IsPlayerInAnyVehicle(strval(tmp)))
{
new ID;
new Float:health;
new Float, Float:y, Float:z, string[100];
if(GetPVarInt(playerid,"CMDABUSE1")>GetTickCount() ) return SendClientMessage(playerid,0xFF0000AA,"Please Wait Before Fish Slapping Someone Again.");
SetPVarInt(playerid,"CMDABUSE1",GetTickCount()+600 00);
GetPlayerPos(ID, x, y, z);
SetPlayerPos(ID, x, y, z+1.5);
GetPlayerHealth(ID,health);
SetPlayerHealth(ID, health-5);
PlayerPlaySound(playerid,1190,0.0,0.0,0.0);
PlayerPlaySound(ID,1190,0.0,0.0,0.0);
format(string, 100, "You have Used Fishslap", name, ID);
SendClientMessage(playerid, COLOR_YELLOW, string);
SetPlayerWantedLevel(playerid,GetPlayerWantedLevel (playerid)+ 1);
return true;
}
else
{
new errormsg[250];
new blown[MAX_PLAYER_NAME];
GetPlayerName(strval(tmp), blown, sizeof(blown));
format(errormsg, sizeof(errormsg), "%s[ID:%d] is in a Vehicle. You cannot fishslap the person inside a vehicle.", blown, strval(tmp));
SendClientMessage(playerid, ERROR, errormsg);
return true;
}
}
else return SendClientMessage(playerid, ERROR, "You cannot fishslap anyone from inside a vehicle.");
}
else
{
new errormsg[250];
new blown[MAX_PLAYER_NAME];
GetPlayerName(strval(tmp), blown, sizeof(blown));
format(errormsg, sizeof(errormsg), "%s[ID:%d] is dead.", blown, strval(tmp));
SendClientMessage(playerid, ERROR, errormsg);
return true;
}
}
else return SendClientMessage(playerid,0xFF0000AA,"Cannot Fishslap When Your Dead.");
}
else return SendClientMessage(playerid,0xFF0000AA,"Nobody Is Close Enough To Fishslap.");
}
else return SendClientMessage(playerid,0xFF0000AA,"You Cannot Slap YourSelf!");
}
else return SendClientMessage(playerid,0xFF0000AA,"Only Civilians Can Fishslap People.");
}


Re: command problem with id 0 - MWhite_005 - 23.07.2011

sry for the mess i dont know how to get the [pawn]


Re: command problem with id 0 - MoroDan - 23.07.2011

Ok, check this out:
PHP код:
if(strcmp(cmd"/fishslap"true) == 0)
{
    
tmp strtok(cmdtextidx);
    new 
targetid strval(tmp);
    if(!
IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1"[ERROR]: That player is not connected !");
    
    if(
gTeam[playerid] == CIVILIAN || gTeam[playerid] == GAZA)
    {
        if(
playerid != targetid)
        {
            if(
GetDistanceBetweenPlayers(playeridtargetid) <= 4)
            {
                if(
IsPlayerSpawned(playerid))
                {
                    if(
IsPlayerSpawned(targetid))
                    {
                        if(!
IsPlayerInAnyVehicle(playerid))
                        {
                            if(!
IsPlayerInAnyVehicle(targetid))
                            {
                                new 
ID;
                                new 
Float:health;
                                new 
FloatFloat:yFloat:zstring[100];
                                if(
GetPVarInt(playerid,"CMDABUSE1")>GetTickCount() ) return SendClientMessage(playerid,0xFF0000AA,"Please Wait Before Fish Slapping Someone Again.");
                                
SetPVarInt(playerid,"CMDABUSE1",GetTickCount()+600 00);
                                
GetPlayerPos(IDxyz);
                                
SetPlayerPos(IDxyz+1.5);
                                
GetPlayerHealth(ID,health);
                                
SetPlayerHealth(IDhealth-5);
                                
PlayerPlaySound(playerid,1190,0.0,0.0,0.0);
                                
PlayerPlaySound(ID,1190,0.0,0.0,0.0);
                                
format(string100"You have Used Fishslap"nameID);
                                
SendClientMessage(playeridCOLOR_YELLOWstring);
                                
SetPlayerWantedLevel(playerid,GetPlayerWantedLevel (playerid)+ 1);
                                return 
true;
                            }
                            else
                            {
                                new 
errormsg[250];
                                new 
blown[MAX_PLAYER_NAME];
                                
GetPlayerName(targetidblownsizeof(blown));
                                
format(errormsgsizeof(errormsg), "%s[ID:%d] is in a Vehicle. You cannot fishslap the person inside a vehicle."blowntargetid);
                                
SendClientMessage(playeridERRORerrormsg);
                                return 
true;
                            }
                        }
                        else return 
SendClientMessage(playeridERROR"You cannot fishslap anyone from inside a vehicle.");
                    }
                    else
                    {
                        new 
errormsg[250];
                        new 
blown[MAX_PLAYER_NAME];
                        
GetPlayerName(targetidblownsizeof(blown));
                        
format(errormsgsizeof(errormsg), "%s[ID:%d] is dead."blowntargetid);
                        
SendClientMessage(playeridERRORerrormsg);
                        return 
true;
                    }
                }
                else return 
SendClientMessage(playerid,0xFF0000AA,"Cannot Fishslap When Your Dead.");
            }
            else return 
SendClientMessage(playerid,0xFF0000AA,"Nobody Is Close Enough To Fishslap.");
        }
        else return 
SendClientMessage(playerid,0xFF0000AA,"You Cannot Slap YourSelf!");
    }
    else return 
SendClientMessage(playerid,0xFF0000AA,"Only Civilians Can Fishslap People.");




Re: command problem with id 0 - MWhite_005 - 23.07.2011

thank you for the pawn code


Re: command problem with id 0 - MWhite_005 - 23.07.2011

it still did the same thing MoroDan


Re: command problem with id 0 - MWhite_005 - 23.07.2011

when i try to excute the command it says 'Cannot Fishslap your self"


Re: command problem with id 0 - MoroDan - 23.07.2011

Quote:
Originally Posted by MWhite_005
Посмотреть сообщение
when i try to excute the command it says 'Cannot Fishslap your self"
Lol, but you didn't say that :P.
PHP код:
if(strcmp(cmd"/fishslap"true) == 0)
{
    
tmp strtok(cmdtextidx);
    new 
targetid strval(tmp);
    if(!
IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1"[ERROR]: That player is not connected !");
    if(
gTeam[playerid] == CIVILIAN || gTeam[playerid] == GAZA)
    {
        if(
GetDistanceBetweenPlayers(playeridtargetid) <= 4)
        {
            if(
IsPlayerSpawned(playerid))
            {
                if(
IsPlayerSpawned(targetid))
                {
                    if(!
IsPlayerInAnyVehicle(playerid))
                    {
                        if(!
IsPlayerInAnyVehicle(targetid))
                        {
                            new 
ID;
                            new 
Float:health;
                            new 
FloatFloat:yFloat:zstring[100];
                            if(
GetPVarInt(playerid,"CMDABUSE1")>GetTickCount() ) return SendClientMessage(playerid,0xFF0000AA,"Please Wait Before Fish Slapping Someone Again.");
                            
SetPVarInt(playerid,"CMDABUSE1",GetTickCount()+600 00);
                            
GetPlayerPos(IDxyz);
                            
SetPlayerPos(IDxyz+1.5);
                            
GetPlayerHealth(ID,health);
                            
SetPlayerHealth(IDhealth-5);
                            
PlayerPlaySound(playerid,1190,0.0,0.0,0.0);
                            
PlayerPlaySound(ID,1190,0.0,0.0,0.0);
                            
format(string100"You have Used Fishslap"nameID);
                            
SendClientMessage(playeridCOLOR_YELLOWstring);
                            
SetPlayerWantedLevel(playerid,GetPlayerWantedLevel (playerid)+ 1);
                            return 
true;
                        }
                        else
                        {
                            new 
errormsg[250];
                            new 
blown[MAX_PLAYER_NAME];
                            
GetPlayerName(targetidblownsizeof(blown));
                            
format(errormsgsizeof(errormsg), "%s[ID:%d] is in a Vehicle. You cannot fishslap the person inside a vehicle."blowntargetid);
                            
SendClientMessage(playeridERRORerrormsg);
                            return 
true;
                        }
                    }
                    else return 
SendClientMessage(playeridERROR"You cannot fishslap anyone from inside a vehicle.");
                }
                else
                {
                    new 
errormsg[250];
                    new 
blown[MAX_PLAYER_NAME];
                    
GetPlayerName(targetidblownsizeof(blown));
                    
format(errormsgsizeof(errormsg), "%s[ID:%d] is dead."blowntargetid);
                    
SendClientMessage(playeridERRORerrormsg);
                    return 
true;
                }
            }
            else return 
SendClientMessage(playerid,0xFF0000AA,"Cannot Fishslap When Your Dead.");
        }
        else return 
SendClientMessage(playerid,0xFF0000AA,"Nobody Is Close Enough To Fishslap.");
    }
    else return 
SendClientMessage(playerid,0xFF0000AA,"Only Civilians Can Fishslap People.");