SA-MP Forums Archive
Why its send two times (ONPLAYERDEATH) - 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: Why its send two times (ONPLAYERDEATH) (/showthread.php?tid=630013)



Why its send two times (ONPLAYERDEATH) - Pokemon64 - 07.03.2017

Hi
this message duplicate if i infect anyone. It's sending two times.
Код:
    if(teams[playerid] == TEAM_ZOMBIE)
    {
    if(pInfo[playerid][pZombieClass] == BOOMERZOMBIE)
    {
    new explodecount;
    GetPlayerPos(playerid,Float:x,Float:y,Float:z);
    CreateExplosion(Float:x,Float:y,Float:z,0,6.0);
    foreach(new i : Player)
    {
    GetClosestPlayer(i);
    if(IsPlayerConnected(i))
    {
   	switch(GetPlayerSkin(i))
    {
    case NON_IMMUNE:
    {
    if(i == playerid) continue;
    if(IsPlayerInRangeOfPoint(i,7.0,Float:x,Float:y,Float:z))
    {
    if(pInfo[i][IsPlayerInfected] == 0)
    {
    InfectPlayerStandard(i);
    explodecount++;
    }
    }
    }
    }
    }
    }
    if(explodecount > 0)
    {
    new zmstring2[256],pNames[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pNames,sizeof(pNames));
    format(zmstring2,sizeof(zmstring2),""COL_GREEN"%s has been infected "COL_WHITE"%i players.",pNames,explodecount);
    SendClientMessageToAll(-1,zmstring2);
    }
    }
    }
	}



Re: Why its send two times (ONPLAYERDEATH) - K9IsGodly - 07.03.2017

I would bet because you don't have a break; statement so that it just drops through and repeats the message since there's no default anyway.


Re: Why its send two times (ONPLAYERDEATH) - Pokemon64 - 07.03.2017

So should i add return?


Re: Why its send two times (ONPLAYERDEATH) - TitanX - 07.03.2017

Quote:
Originally Posted by Pokemon64
Посмотреть сообщение
So should i add return?
PHP код:
break; 
not return


Re: Why its send two times (ONPLAYERDEATH) - Pokemon64 - 07.03.2017

Lol ok i will test it


Re: Why its send two times (ONPLAYERDEATH) - Sew_Sumi - 07.03.2017

Please for the love of god INDENT!


Re: Why its send two times (ONPLAYERDEATH) - Sithis - 07.03.2017

Indent your damn code, it hurts my eyes and makes me want to kill cute babies.


Re: Why its send two times (ONPLAYERDEATH) - Pokemon64 - 07.03.2017

Well you dont need to repeat all the time