14.10.2016, 17:59
someone could teach me how to make a radiation system? for example, you have an area made by gang zone and if the person entering this area the level of radiation rises, reaching 100% the player dies.
Hello.
You can do this with a timer. I recommend to use the streamer because with that it's very easy to check if a player is in a gang zone. Then you can check if the player is in this zone and start the timer (and increase an variable always with e.g. 10). If the variable is on 100 the player die and when the player leave the zone before the variable is on 100 you can kill the timer and put the variable on 0. Maybe you can do it yourself. If not you can send us your currently code (with that you tested it) and say us what the problem is. ![]() |
enum Radiation
{
ZoneID,
ZonePos[4]
}
new gRadiation[200][Radiation] =
{
{0, 0, 5, 5},
{10, 10, 15, 15}
};
Functions (Streamer):
CreateDynamicRectangle, CreateDynamicCircle, IsPlayerInArea Variables: To store the radiation zones, use a enumerator and array; PHP код:
|
public OnPlayerEnterDynamicArea(playerid, areaid) {
for (new zone=0; zone<MAX_ZONES; zone++) {
if (areaid==zones[zone]) {
new msg[90];
format(msg, 90, "Welcome to %s", zones_text[zone]);
SendClientMessage(playerid, 0xFFFFFFFF, msg);
}
}
return 1;
}
public OnPlayerLeaveDynamicArea(playerid, areaid) {
for (new zone=0; zone<MAX_ZONES; zone++) {
if (areaid==zones[zone]) {
new msg[90];
format(msg, 90, "Goodbye from %s", zones_text[zone]);
SendClientMessage(playerid, 0xFFFFFFFF, msg);
}
}
return 1;
}
//under the includes:
new RadiationPlayer[MAX_PLAYERS],RadiationTimer[MAX_PLAYERS];
//your callback
public OnPlayerEnterDynamicArea(playerid, areaid) {
for (new zone=0; zone<MAX_ZONES; zone++) {
if (areaid==zones[zone]) {
new msg[90];
format(msg, 90, "Welcome to %s", zones_text[zone]);
SendClientMessage(playerid, 0xFFFFFFFF, msg);
RadiationTimer[playerid] = SetTimerEx("OnPlayerRadiationSystem",1000,1,"ii",playerid,areaid);
}
}
return 1;
}
//callback for the timer
forward OnPlayerRadiationSystem(playerid,areaid);
public OnPlayerRadiationSystem(playerid,areaid)
{
if(IsPlayerInDynamicArea(playerid,areaid))
{
RadiationPlayer[playerid] += 10;
if(RadiationPlayer[playerid] == 100)
{
SetPlayerHealth(playerid,0.0);
SendClientMessage(playerid,-1,"Your Radiation is on 100! You die!");
return 1;
}
new string[50];
format(string,sizeof string,"RADIATION: + 10 (current: %d)",RadiationPlayer[playerid]);
SendClientMessage(playerid,-1,string);
}
return 1;
}
//your callback
public OnPlayerLeaveDynamicArea(playerid, areaid) {
for (new zone=0; zone<MAX_ZONES; zone++) {
if (areaid==zones[zone]) {
new msg[90];
format(msg, 90, "Goodbye from %s", zones_text[zone]);
SendClientMessage(playerid, 0xFFFFFFFF, msg);
KillTimer(RadiationTimer[playerid]);
}
}
return 1;
}