Vehicle damage check not working -
Aerotactics - 24.03.2014
I have this vehicle damage check and is a player not in a vehicle check and it only seems to work for one playerid at a time. As in, other players' cars blow up and they don't get a client message. It was originally under a foreach loop and wasn't working either.
pawn Код:
public DerbySys(playerid) //
{
if (IsPlayerInRangeOfPoint(playerid, 500, -1364,1004.5,1220)) //map coords...
{
if (!IsPlayerInAnyVehicle(playerid))
{
GetDerbyCar(playerid);
return 1;
}
if (IsPlayerInVehicle(playerid,RandDerbyCar[playerid]))
{
new Float:Vhealth;
GetVehicleHealth(RandDerbyCar[playerid],Vhealth);
if (Vhealth <= 250)
{
DestroyVehicle(RandDerbyCar[playerid]);
SendClientMessage(playerid,0xFFFFFFFF,"Vehicle was destroyed. New vehicle created.");
return 1;
}
}
}
return 1;
}
Re: Vehicle damage check not working -
]Rafaellos[ - 24.03.2014
They won't get a new vehicle because you don't give it to them.
pawn Код:
if (Vhealth <= 250)
{
DestroyVehicle(RandDerbyCar[playerid]);
SendClientMessage(playerid,0xFFFFFFFF,"Vehicle was destroyed. New vehicle created.");
GetDerbyCar(playerid);
return 1;
}
Re: Vehicle damage check not working -
Aerotactics - 24.03.2014
That's not the issue. They should have their vehicle destroyed, and a message should be sent. It only works for 1 player, the others have no effect.
Re: Vehicle damage check not working -
Hanuman - 24.03.2014
How u are using DerbySys? As a timer under OnGamemodeInit?
Re: Vehicle damage check not working -
Aerotactics - 24.03.2014
Quote:
Originally Posted by Hanuman
How u are using DerbySys? As a timer under OnGamemodeInit?
|
Yes, as a timer. Is that the issue?
Re: Vehicle damage check not working -
Konstantinos - 24.03.2014
The issue is probably that you used SetTimer and in the callback you used playerid as parameter (SetTimerEx has parameters only, SetTimer not).
Show us how you set the timer, just to be sure.
Re: Vehicle damage check not working -
Aerotactics - 24.03.2014
pawn Код:
SetTimer("DerbySys",1000,1);
If that's the case should it be:
pawn Код:
SetTimerEx("DerbySys",1000,true,"playerid");
Re: Vehicle damage check not working -
Zeppo - 24.03.2014
You're setting the timer for one person thats why. Change to a global timer(Place it under OnGameModeInit)
EDIT:
pawn Код:
SetTimer("DerbySys",1000, 1);
EDIT2:
I read that wrong. No don't use the second one, the first one should work.
Re: Vehicle damage check not working -
Konstantinos - 24.03.2014
If you keep this in OnGameModeInit/OnFilterScriptInit:
pawn Код:
SetTimer("DerbySys",1000,1);
then change to:
pawn Код:
forward DerbySys();
public DerbySys()
{
for (new playerid; playerid != MAX_PLAYERS; ++playerid)
{
if (!IsPlayerConnected(playerid) || !IsPlayerInRangeOfPoint(playerid, 500, -1364,1004.5,1220)) continue;
if (!IsPlayerInAnyVehicle(playerid))
{
GetDerbyCar(playerid);
continue;
}
if (IsPlayerInVehicle(playerid,RandDerbyCar[playerid]))
{
new Float:Vhealth;
GetVehicleHealth(RandDerbyCar[playerid],Vhealth);
if (Vhealth <= 250)
{
DestroyVehicle(RandDerbyCar[playerid]);
SendClientMessage(playerid,0xFFFFFFFF,"Vehicle was destroyed. New vehicle created.");
}
}
}
}
Else you'd have to set the timer when a player joins the derby:
pawn Код:
SetTimerEx("DerbySys", 1000, true, "i", playerid);
and use it as you have it but keep in mind to store the timer ID in an array and when a player leaves derby to destroy the timer.
Re: Vehicle damage check not working -
Aerotactics - 24.03.2014
I implemented your code into the script. I won't know if it works until one of the Beta Testers is up, or Ranger is up. Thanks for the help and the rewrite. I left you credit in the script.