SA-MP Forums Archive
How need make player around me losing hp - 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: How need make player around me losing hp (/showthread.php?tid=630145)



How need make player around me losing hp - henkas - 09.03.2017

Hi.
I have no idea how should i make stuff like this. If someone is around me start losing hp bat if he run away he don't lose hp. Its like radioactive zone.


Re: How need make player around me losing hp - Toroi - 09.03.2017

You could use Icognito's Streamer for that

https://sampforum.blast.hk/showthread.php?tid=102865

Код:
native STREAMER_TAG_AREA CreateDynamicSphere(Float:x, Float:y, Float:z, Float:size, worldid = -1, interiorid = -1, playerid = -1);

native AttachDynamicAreaToPlayer(STREAMER_TAG_AREA areaid, playerid, Float:offsetx = 0.0, Float:offsety = 0.0, Float:offsetz = 0.0);

forward OnPlayerEnterDynamicArea(playerid, STREAMER_TAG_AREA areaid);



Re: How need make player around me losing hp - henkas - 09.03.2017

Quote:
Originally Posted by Troydere
Посмотреть сообщение
You could use Icognito's Streamer for that

https://sampforum.blast.hk/showthread.php?tid=102865

Код:
native STREAMER_TAG_AREA CreateDynamicSphere(Float:x, Float:y, Float:z, Float:size, worldid = -1, interiorid = -1, playerid = -1);

native AttachDynamicAreaToPlayer(STREAMER_TAG_AREA areaid, playerid, Float:offsetx = 0.0, Float:offsety = 0.0, Float:offsetz = 0.0);

forward OnPlayerEnterDynamicArea(playerid, STREAMER_TAG_AREA areaid);
Example how use it?


Re: How need make player around me losing hp - Toroi - 09.03.2017

I'd create a function with the hp loss with a player timer of 1 second under OnPlayerEnterDynamicArea.

If you're doing it this way, remember to kill the timer in OnPlayerLeaveDynamicArea and OnPlayerDisconnect, as when someone disconnects inside a Dynamic Area, it does not count as if they left.

PHP код:
new badtimer[MAX_PLAYERS];
new 
dainameecErea
public OnGameModeInit
{
    
dainameecErea CreateDynamicSphere(0,0,0,10);
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    if(
check if its youAttachDynamicAreaToPlayer(dainameecEreaplayeridFloat:offsetx 0.0Float:offsety 0.0Float:offsetz 0.0);
    return 
1;
}
public 
OnPlayerEnterDynamicArea(playerid,STREAMER_TAG_AREA areaid)
{
    
badtimer[playerid] = SetTimerEx("SuckMyBlood",1000,true,"i",playerid);
    return 
1;
}
SuckMyBlood(playerid)
{
    new 
Float:healtu;
    
GetPlayerHealth(playerid,healtu);
    
SetPlayerHealth(playerid,healtu 15.0);
    return 
1;
}
public 
OnPlayerDisconnect // kill the timer
public OnPlayerLeaveDynamicArea // kill the timer 



Re: How need make player around me losing hp - henkas - 10.03.2017

Quote:
Originally Posted by Troydere
Посмотреть сообщение
I'd create a function with the hp loss with a player timer of 1 second under OnPlayerEnterDynamicArea.

If you're doing it this way, remember to kill the timer in OnPlayerLeaveDynamicArea and OnPlayerDisconnect, as when someone disconnects inside a Dynamic Area, it does not count as if they left.

PHP код:
new badtimer[MAX_PLAYERS];
new 
dainameecErea
public OnGameModeInit
{
    
dainameecErea CreateDynamicSphere(0,0,0,10);
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    if(
check if its youAttachDynamicAreaToPlayer(dainameecEreaplayeridFloat:offsetx 0.0Float:offsety 0.0Float:offsetz 0.0);
    return 
1;
}
public 
OnPlayerEnterDynamicArea(playerid,STREAMER_TAG_AREA areaid)
{
    
badtimer[playerid] = SetTimerEx("SuckMyBlood",1000,true,"i",playerid);
    return 
1;
}
SuckMyBlood(playerid)
{
    new 
Float:healtu;
    
GetPlayerHealth(playerid,healtu);
    
SetPlayerHealth(playerid,healtu 15.0);
    return 
1;
}
public 
OnPlayerDisconnect // kill the timer
public OnPlayerLeaveDynamicArea // kill the timer 
Ok thanks i will test it.


Re: How need make player around me losing hp - henkas - 10.03.2017

Quote:
Originally Posted by Troydere
Посмотреть сообщение
I'd create a function with the hp loss with a player timer of 1 second under OnPlayerEnterDynamicArea.

If you're doing it this way, remember to kill the timer in OnPlayerLeaveDynamicArea and OnPlayerDisconnect, as when someone disconnects inside a Dynamic Area, it does not count as if they left.

PHP код:
new badtimer[MAX_PLAYERS];
new 
dainameecErea
public OnGameModeInit
{
    
dainameecErea CreateDynamicSphere(0,0,0,10);
    return 
1;
}
public 
OnPlayerConnect(playerid)
{
    if(
check if its youAttachDynamicAreaToPlayer(dainameecEreaplayeridFloat:offsetx 0.0Float:offsety 0.0Float:offsetz 0.0);
    return 
1;
}
public 
OnPlayerEnterDynamicArea(playerid,STREAMER_TAG_AREA areaid)
{
    
badtimer[playerid] = SetTimerEx("SuckMyBlood",1000,true,"i",playerid);
    return 
1;
}
SuckMyBlood(playerid)
{
    new 
Float:healtu;
    
GetPlayerHealth(playerid,healtu);
    
SetPlayerHealth(playerid,healtu 15.0);
    return 
1;
}
public 
OnPlayerDisconnect // kill the timer
public OnPlayerLeaveDynamicArea // kill the timer 
P.S Where is distance to player, when losing hp will start working?


Re: How need make player around me losing hp - Toroi - 10.03.2017

Here

Код:
dainameecErea = CreateDynamicSphere(0,0,0,10);
Код:
CreateDynamicSphere(Float:x, Float:y, Float:z, Float:size, worldid = -1, interiorid = -1, playerid = -1);
In addition to my previous post. You could move the function CreateDynamicSphere under OnPlayerConnect and delete it under OnPlayerDisconnect, together with the timer, in order to make things work efficiently.


Re: How need make player around me losing hp - henkas - 10.03.2017

Quote:
Originally Posted by Troydere
Посмотреть сообщение
Here

Код:
dainameecErea = CreateDynamicSphere(0,0,0,10);
Код:
CreateDynamicSphere(Float:x, Float:y, Float:z, Float:size, worldid = -1, interiorid = -1, playerid = -1);
In addition to my previous post. You could move the function CreateDynamicSphere under OnPlayerConnect and delete it under OnPlayerDisconnect, together with the timer, in order to make things work efficiently.
Ok i will do it. Will it not bug in interior?


Re: How need make player around me losing hp - henkas - 10.03.2017

error 017: undefined symbol "offsetx"
warning 215: expression has no effect
error 017: undefined symbol "offsety"
warning 215: expression has no effect
error 017: undefined symbol "offsetz"
fatal error 107: too many error messages on one line

Код:
if AttachDynamicAreaToPlayer(dainameecErea, playerid, Float:offsetx = 0.0, Float:offsety = 0.0, Float:offsetz = 0.0);



Re: How need make player around me losing hp - Toroi - 10.03.2017

That was the template, you can add the value you want there, it's 0.0 by default, so lets leave it 0.0 in this case:

Код:
AttachDynamicAreaToPlayer(dainameecErea, playerid);
My intention was not to give you a copy-paste code but to explain you how does it work.

The provided code was not intended to work although it may work.