PDA

View Full Version : zombie spawn protection


sanamalik400
12/09/2015, 11:07 PM
i m new in samp and new in scripting..anyone can make this code for spawn kill zombies?
if a human shoots a zombie at spawn point he also gets the same damage as the zombie does, like a human shot a bullet of any gun in a zombie standing at spawn point he also gets the damage,
If bullet shot= Equal damage
and if zombie die = SetHumanHealth 0
see attached pic
Help= +1 rep For helper

KillerDVX
12/09/2015, 11:30 PM
Hello sanamalik400,

I've got this code for you,

public OnPlayerShootPlayer(Shooter,Target,Float:HealthLos t,Float:ArmourLost)
{
if (IsPlayerInRangeOfPoint(Target, 2.0, the x pos of the player spawn points, y, z))
{
new Float:health;
GetPlayerHealth(Shooter,health);
SetPlayerHealth(Shooter, health-5); // It will decrease 5 hp at each shoot
return 1;
}

For the "OnPlayerShootPlayer", it has an include, you have to download it : http://forum.sa-mp.com/showthread.php?p=937824

- KillerDVX.

sanamalik400
12/09/2015, 11:34 PM
if player assasin one shoot =1 kill then??
or i make damages for all classes??
Anyway thanks

sanamalik400
13/09/2015, 11:34 AM
KillerDVX Your code not working :P

sanamalik400
13/09/2015, 11:57 AM
no one helping :(

ax1
13/09/2015, 01:12 PM
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
if(issuerid != INVALID_PLAYER_ID)
{
if(IsPlayerInRangeOfPoint(playerid, range, x, y, z))
{
SetPlayerHealth(playerid, GetPlayerHealth(playerid)+amount);
SetPlayerHealth(issuerid, GetPlayerHealth(playerid)-amount);
}
}
return 1;
}

X337
13/09/2015, 01:23 PM
SetPlayerHealth(playerid, GetPlayerHealth(playerid)+amount);
SetPlayerHealth(issuerid, GetPlayerHealth(playerid)-amount);



public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
if(issuerid != INVALID_PLAYER_ID)
{
if(IsPlayerInRangeOfPoint(playerid, range, x, y, z))
{
new Float:hp;
GetPlayerHealth(playerid, hp);
SetPlayerHealth(playerid, hp + amount);
GetPlayerHealth(playerid, hp);
SetPlayerHealth(issuerid, hp - amount);
}
}
return 1;
}


The right syntax is GetPlayerHealth(playerid, &Float:health);

ax1
13/09/2015, 01:25 PM
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid, bodypart)
{
if(issuerid != INVALID_PLAYER_ID)
{
if(IsPlayerInRangeOfPoint(playerid, range, x, y, z))
{
new Float:hp;
GetPlayerHealth(playerid, hp);
SetPlayerHealth(playerid, hp + amount);
GetPlayerHealth(playerid, hp);
SetPlayerHealth(issuerid, hp - amount);
}
}
return 1;
}


The right syntax is GetPlayerHealth(playerid, &Float:health);

My bad :D I didn't even compile my code

KillerDVX
13/09/2015, 03:51 PM
Why it's not working ? are you getting errors ? if yes, please paste them here.

sanamalik400
13/09/2015, 06:36 PM
Wait i compile

sanamalik400
13/09/2015, 06:49 PM
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1579) : warning 219: local variable "x" shadows a variable at a preceding level
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1579) : warning 219: local variable "y" shadows a variable at a preceding level
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1579) : warning 219: local variable "z" shadows a variable at a preceding level
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1671) : error 017: undefined symbol "range"
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1673) : warning 219: local variable "hp" shadows a variable at a preceding level
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1681) : error 055: start of function body without function header
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1684) : error 010: invalid function or declaration
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1686) : error 010: invalid function or declaration
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1688) : error 010: invalid function or declaration
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1690) : error 010: invalid function or declaration
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1693) : error 021: symbol already defined: "GetPlayerFacingAngle"
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1696) : error 021: symbol already defined: "SetPlayerVelocity"
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1703) : error 010: invalid function or declaration
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1705) : error 010: invalid function or declaration
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1707) : error 010: invalid function or declaration
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1709) : error 010: invalid function or declaration
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1712) : error 021: symbol already defined: "GetPlayerHealth"
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1718) : error 010: invalid function or declaration
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1720) : error 010: invalid function or declaration
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1722) : error 010: invalid function or declaration
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1729) : error 010: invalid function or declaration
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1731) : error 010: invalid function or declaration
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1733) : error 010: invalid function or declaration
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1735) : error 010: invalid function or declaration
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1737) : error 021: symbol already defined: "hp"
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1745) : error 010: invalid function or declaration
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1747) : error 010: invalid function or declaration
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1749) : error 010: invalid function or declaration
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1751) : error 010: invalid function or declaration
C:\Users\muaz baba\Desktop\zGM[Fahad]\gamemodes\zma1.pwn(1753) : error 021: symbol already defined: "hp"

Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


26 Errors.
X337 see pawno errors

sanamalik400
13/09/2015, 06:56 PM
Killer ur cod compiled but 3 errors tag mismatch :P :D
public OnPlayerShootPlayer(Shooter,Target,Float:HealthLos t,Float:ArmourLost)
{
if (IsPlayerInRangeOfPoint(Target, 2.0, ZombieSpawnX, ZombieSpawnY, ZombieSpawnZ))
{
new Float:health;
GetPlayerHealth(Shooter,health);
SetPlayerHealth(Shooter, health-5);
} ///// u was forgot that bracket :D
return 1;
}

KillerDVX
14/09/2015, 10:30 PM
Could you give me the exact lines of the errors ?

sanamalik400
14/09/2015, 11:42 PM
this line..
if (IsPlayerInRangeOfPoint(Target, 2.0, ZombieSpawnX, ZombieSpawnY, ZombieSpawnZ))

KillerDVX
15/09/2015, 10:09 PM
Try changing the "ZombieSpawnX, ZombieSpawnY, ZombieSpawnZ" by an exact number of positions ? I'm not sure..

sanamalik400
15/09/2015, 10:16 PM
wait i try and post here..