SA-MP Forums Archive
Any ideas why system doesn't work? - 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: Any ideas why system doesn't work? (/showthread.php?tid=630617)



Any ideas why system doesn't work? - henkas - 16.03.2017

Hi
I have one bug bat i have no clue why explosion doesn't work if i stand near people bat if i run away and try explode everything ok.

Код:
    if(PRESSED(KEY_WALK))
    {
    new infectedcount;
    if(teams[playerid] == TEAM_ZOMBIE)
    {
    if(pInfo[playerid][pZombieClass] == ADVANCEDBOOMER)
    {
    new victimid = GetClosestPlayer(playerid);
    if(IsPlayerInRangeOfPoint(playerid,4.0,Map[ZombieSpawnX],Map[ZombieSpawnY],Map[ZombieSpawnZ]) || IsPlayerInRangeOfPoint(playerid,4.0,Map[ZombieSpawn2X],Map[ZombieSpawn2Y],Map[ZombieSpawn2Z]))
    {
    GameTextForPlayer(playerid,"~r~You can't!",4000,5);
    }
    else
    {
    switch(GetPlayerSkin(victimid))
	{
    case NON_IMMUNE,249:
	{
    new Float:x,Float:y,Float:z;
    GetPlayerPos(playerid,Float:x,Float:y,Float:z);
    SetPlayerHealth(playerid,0.0);
    CreateExplosion(Float:x,Float:y,Float:z,0,6.0);
    for(new i=0; i<MAX_PLAYERS; i++)
    {
    if(i == playerid) continue;

    if(IsPlayerInRangeOfPoint(i,7.0,Float:x,Float:y,Float:z))
    {
    if(pInfo[i][IsPlayerInfected] == 0)
    {
    infectedcount++;
    InfectPlayerStandard(i);
    }
    }
    }
    if(infectedcount > 0)
    {
    new zmstring2[256],pNames[MAX_PLAYER_NAME];
    GetPlayerName(playerid,pNames,sizeof(pNames));
    format(zmstring2,sizeof(zmstring2),""COL_GREEN">> %s has been explode "COL_WHITE"%i players.",pNames,infectedcount);
    SendClientMessageToAll(-1,zmstring2);
    }
    }
    }
    }
	}
    }
    }
If you know why please explain.


Re: Any ideas why system doesn't work? - Toroi - 16.03.2017

Indent your code and explain yourself quite better, do you get the message 'You can't!' when you try to explode near someone?

Is this needed? It does not look like you need it as later you loop for every player near the bomber anyway
Код:
    switch(GetPlayerSkin(victimid))
	{
    case NON_IMMUNE,249:



Re: Any ideas why system doesn't work? - henkas - 16.03.2017

Quote:
Originally Posted by Troydere
Посмотреть сообщение
Indent your code and explain yourself quite better, do you get the message 'You can't!' when you try to explode near someone?

Is this needed? It does not look like you need it as later you loop for every player near the bomber anyway
Код:
    switch(GetPlayerSkin(victimid))
	{
    case NON_IMMUNE,249:
Says nothing, just cant explode and thats all.


Re: Any ideas why system doesn't work? - henkas - 16.03.2017

I need this because without this i can infect everyone so this code make if player have 249 skin id infection didn't work. Bat with explosion it makes no sense.


Re: Any ideas why system doesn't work? - Toroi - 16.03.2017

No, it does the contrary, it only infects the skin 249. Either remove it or change it for this:

PHP код:
    switch(GetPlayerSkin(victimid))
    {
        case 
NON_IMMUNE,249: return 1;
        default:
    {
    new 
Float:x,Float:y,Float:z;
    
GetPlayerPos(playerid,Float:x,Float:y,Float:z);
    
SetPlayerHealth(playerid,0.0);
//... rest of code 



Re: Any ideas why system doesn't work? - Pokemon64 - 16.03.2017

Quote:
Originally Posted by Troydere
Посмотреть сообщение
No, it does the contrary, it only infects the skin 249. Either remove it or change it for this:

PHP код:
    switch(GetPlayerSkin(victimid))
    {
        case 
NON_IMMUNE,249: return 1;
        default:
    {
    new 
Float:x,Float:y,Float:z;
    
GetPlayerPos(playerid,Float:x,Float:y,Float:z);
    
SetPlayerHealth(playerid,0.0);
//... rest of code 
Fuuu, my mistake yea its infect only the 249 D I made mistake with that explosion i saw its doesnt explode at all. It doesn't matter are you close human or not its just dont functional at all.


Re: Any ideas why system doesn't work? - Toroi - 16.03.2017

I can't tell from your post if it worked or not, but

Try to change the following code order:
Код:
    SetPlayerHealth(playerid,0.0);
    CreateExplosion(Float:x,Float:y,Float:z,0,6.0);
to (also remove the Float tags)
Код:
    CreateExplosion(x,y,z,0,6.0);
    SetPlayerHealth(playerid,0.0);
Remove them here aswell:

Код:
GetPlayerPos(playerid,Float:x,Float:y,Float:z);
to:
Код:
GetPlayerPos(playerid,x,y,z);



Re: Any ideas why system doesn't work? - Pokemon64 - 16.03.2017

Quote:
Originally Posted by Troydere
Посмотреть сообщение
I can't tell from your post if it worked or not, but

Try to change the following code order:
Код:
    SetPlayerHealth(playerid,0.0);
    CreateExplosion(Float:x,Float:y,Float:z,0,6.0);
to (also remove the Float tags)
Код:
    CreateExplosion(x,y,z,0,6.0);
    SetPlayerHealth(playerid,0.0);
Remove them here aswell:

Код:
GetPlayerPos(playerid,Float:x,Float:y,Float:z);
to:
Код:
GetPlayerPos(playerid,x,y,z);
Nothing. Same problem it didn't explode. I have no idea why its didn't work i remember everything was fine and now bugged.


Re: Any ideas why system doesn't work? - henkas - 16.03.2017

Lmao fixed, i take a bit time until i realize problem

This is how code look now
Код:
    if(PRESSED(KEY_WALK))
    {
    new infectedcount;
    if(teams[playerid] == TEAM_ZOMBIE)
    {
    if(pInfo[playerid][pZombieClass] == ADVANCEDBOOMER)
    {
    new victimid = GetClosestPlayer(playerid);
    if(IsPlayerInRangeOfPoint(playerid,4.0,Map[ZombieSpawnX],Map[ZombieSpawnY],Map[ZombieSpawnZ]) || IsPlayerInRangeOfPoint(playerid,4.0,Map[ZombieSpawn2X],Map[ZombieSpawn2Y],Map[ZombieSpawn2Z]))
    {
    GameTextForPlayer(playerid,"~r~You cant explode yourself near zombie spawn!",4000,5);
    }
    else
    {
    new Float:x,Float:y,Float:z;
    GetPlayerPos(playerid,Float:x,Float:y,Float:z);
    SetPlayerHealth(playerid,0.0);
    CreateExplosion(Float:x,Float:y,Float:z,0,6.0);
    switch(GetPlayerSkin(victimid))
    {
    case NON_IMMUNE,249: return 1;
    default:
    {
    for(new i=0; i<MAX_PLAYERS; i++)
    {
    if(i == playerid) continue;

    if(IsPlayerInRangeOfPoint(i,7.0,Float:x,Float:y,Float:z))
    {
    if(pInfo[i][IsPlayerInfected] == 0)
    {
    infectedcount++;
    InfectPlayerStandard(i);
    }
    }
    }
    if(infectedcount > 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,infectedcount);
    SendClientMessageToAll(-1,zmstring2);
    }
    }
	}
    }
    }
    }
    }
Problem was with
Код:
    switch(GetPlayerSkin(victimid))
	{
    case NON_IMMUNE,249:
	{
I need put it after
Код:
    new Float:x,Float:y,Float:z;
    GetPlayerPos(playerid,Float:x,Float:y,Float:z);
    SetPlayerHealth(playerid,0.0);
    CreateExplosion(Float:x,Float:y,Float:z,0,6.0);