SA-MP Forums Archive
ID 0 is acting for `i` in for (new i;i<MAX_PLAYERS;i++) - 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: ID 0 is acting for `i` in for (new i;i<MAX_PLAYERS;i++) (/showthread.php?tid=272391)



ID 0 is acting for `i` in for (new i;i<MAX_PLAYERS;i++) - MWhite_005 - 28.07.2011

Hi again still trying,i realize that the 'i',is the same thing as id 0.For Eg.

GetPlayerHealth(i,health);// In my script this is saying get Id 0 health
SetPlayerHealth(i, health-5);//In my script this is saying set Id 0 health to minus 5

plllllzzzzz,this is my fifth attempt...


Re: ID 0 is acting for `i` in for (new i;i<MAX_PLAYERS;i++) - Grim_ - 28.07.2011

You will need to show us some code! The code with and inside the loop.


Re: ID 0 is acting for `i` in for (new i;i<MAX_PLAYERS;i++) - MWhite_005 - 28.07.2011

if(strcmp(cmd, "/fishslap", true) == 0)
{
for (new i;i<MAX_PLAYERS;i++)
{
tmp = strtok(cmdtext, idx);
if(!IsPlayerConnected(i)) return SendClientMessage(playerid, -1, "[ERROR]: That player is not connected !");
if(gTeam[playerid] == CIVILIAN || gTeam[playerid] == GAZA)
{
new Float,Float:y,Float:z;
GetPlayerPos(i, x, y, z);
if(IsPlayerConnected(i) && IsPlayerInRangeOfPoint(playerid,5,x,y,z))
{

if(playerid != i)
{

if(IsPlayerSpawned(playerid))
{
if(IsPlayerSpawned(i))
{
if(!IsPlayerInAnyVehicle(playerid))
{
if(!IsPlayerInAnyVehicle(i))
{
new Float:health;
if(GetPVarInt(playerid,"CMDABUSE1")>GetTickCount() ) return SendClientMessage(playerid,0xFF0000AA,"Please Wait Before Fish Slapping Someone Again.");
SetPVarInt(playerid,"CMDABUSE1",GetTickCount()+600 00);
SetPlayerPos(i, x, y, z+1.5);
GetPlayerHealth(i,health);
SetPlayerHealth(i, health-5);
PlayerPlaySound(i,1190,0.0,0.0,0.0);
PlayerPlaySound(playerid,1190,0.0,0.0,0.0);
SendClientMessage(playerid,COLOR_YELLOW,"You Have Used Fishslap.");
SendClientMessage(i,0xFF0000AA,"You Have Been Fishslapped.");
SetPlayerWantedLevel(playerid,GetPlayerWantedLevel (playerid)+ 1);
return 1;
}
else
{
new errormsg[250];
new blown[MAX_PLAYER_NAME];
GetPlayerName(i, 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(i, 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,"You Cannot Slap YourSelf!");
}
else return SendClientMessage(playerid,0xFF0000AA,"Nobody Is Close Enough To Fishslap.");
}
else return SendClientMessage(playerid,0xFF0000AA,"Only Civilians Can Fishslap People.");
}
}


Re: ID 0 is acting for `i` in for (new i;i<MAX_PLAYERS;i++) - Toreno - 28.07.2011

I didn't test it or anything, but check it anyways.
pawn Код:
if(strcmp(cmd, "/fishslap", true) == 0) {
    tmp = strtok(cmdtext, idx);
    if(!strlen(tmp)) return SendClientMessage(playerid, -1, "USAGE: /slap [ID]");
    new targetid;
    targetid = ReturnUser(tmp);
    if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "SERVER: Player ID is not connected");
    if(playerid == targetid) return SendClientMessage(playerid, -1, "SERVER: You can't fishslap yourself");
    if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1, "SERVER: You can't fishslap when you inside a vehicle");
    if(IsPlayerInAnyVehicle(targetid)) return SendClientMessage(playerid, -1, "SERVER: You can't fishslap player ID if he's inside a vehicle");
    if(gTeam[playerid] == CIVILIAN || gTeam[playerid] == GAZA) {
        new Float,Float:y,Float:z;
        GetPlayerPos(targetid, x, y, z);
        if(IsPlayerInRangeOfPoint(playerid, 5, x, y, z)) {
            new Float:health;
            if(GetPVarInt(playerid,"CMDABUSE1")>GetTickCount() ) return SendClientMessage(playerid,0xFF0000AA,"Please Wait Before Fish Slapping Someone Again.");
            SetPVarInt(playerid,"CMDABUSE1",GetTickCount()+600 00);
            SetPlayerPos(i, x, y, z+1.5);
            GetPlayerHealth(i,health);
            SetPlayerHealth(i, health-5);
            PlayerPlaySound(i,1190,0.0,0.0,0.0);
            PlayerPlaySound(playerid,1190,0.0,0.0,0.0);
            SendClientMessage(playerid,COLOR_YELLOW,"You Have Used Fishslap.");
            SendClientMessage(i,0xFF0000AA,"You Have Been Fishslapped.");
            SetPlayerWantedLevel(playerid,GetPlayerWantedLevel (playerid)+ 1);
            return 1;
        } else return SendClientMessage(playerid, -1, "SERVER: Player ID isn't close enough");
    } else return SendClientMessage(playerid, -1, "SERVER: Only civilians can fishslap people.");
    return 1;
}



Re: ID 0 is acting for `i` in for (new i;i<MAX_PLAYERS;i++) - MWhite_005 - 28.07.2011

ty im going to try it


Re: ID 0 is acting for `i` in for (new i;i<MAX_PLAYERS;i++) - (SF)Noobanatior - 28.07.2011

whitebread?