How need make player around me losing hp
#1

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.
Reply
#2

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);
Reply
#3

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?
Reply
#4

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 
Reply
#5

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.
Reply
#6

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?
Reply
#7

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.
Reply
#8

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?
Reply
#9

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);
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)