OnPlayerUpdate causing errors... -
Ash. - 12.08.2010
I am using OnPlayerUpdate in a script of mine, basically, every time i insert this "OnPlayerUpdate" function into my script, it stops all players from syncing, and whenever i go near a player they appear to be stood still, or stood on top of their vehicle (if they are in one).
Here is the OnPlayerUpdate section:
pawn Код:
public OnPlayerUpdate(playerid)
{
if(GetPlayerTeam(playerid) == 1)
{
if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)) == 0)
{
if(gMissionInt[playerid] == 1)
{
GameTextForPlayer(playerid, "Reattach your trailer!", 1500, 4);
}
return 1;
}
}
if(IsPlayerInAnyVehicle(playerid) == 0)
{
if(gMissionInt[playerid] == 1)
{
GameTextForPlayer(playerid, "Get back in you're vehicle!", 1500, 4);
}
}
//STOP = Broken Down :)
if(IsPlayerInAnyVehicle(playerid) == 1)
{
new Float:VehicleHealth;
GetVehicleHealth(GetPlayerVehicleID(playerid), VehicleHealth);
if(VehicleHealth < 250)
{
GameTextForPlayer(playerid, "You have broken down, ~n~~r~call /assistance", 1001, 5);
SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.0, 0.0, 0.0);
}
}
return 0;
}
This error only happens when OnPlayerUpdate is called. If i remove the above code from my script, everything works perfectly again.
What is wrong?
Thanks
Ash
Re: OnPlayerUpdate causing errors... -
Johnny_Xayc - 12.08.2010
public OnPlayerUpdate(playerid)
{
if(GetPlayerTeam(playerid) == 1)
{
if(IsTrailerAttachedToVehicle(GetPlayerVehicleID(p layerid)) == 0)
{
if(gMissionInt[playerid] == 1)
{
GameTextForPlayer(playerid, "Reattach your trailer!", 1500, 4);
}
return 1;
}
}
if(IsPlayerInAnyVehicle(playerid) == 0)
{
if(gMissionInt[playerid] == 1)
{
GameTextForPlayer(playerid, "Get back in you're vehicle!", 1500, 4);
}
}
//STOP = Broken Down
if(IsPlayerInAnyVehicle(playerid) == 1)
{
new Float:VehicleHealth;
GetVehicleHealth(GetPlayerVehicleID(playerid), VehicleHealth);
if(VehicleHealth < 250)
{
GameTextForPlayer(playerid, "You have broken down, ~n~~r~call /assistance", 1001, 5);
SetVehicleVelocity(GetPlayerVehicleID(playerid), 0.0, 0.0, 0.0);
}
}
return 1;
}
Re: OnPlayerUpdate causing errors... -
JaTochNietDan - 12.08.2010
Because you're returning 0 at the end of the code, which stops the syncronisation of the player.
Re: OnPlayerUpdate causing errors... -
pmk1 - 12.08.2010
i think it's your return 0 at the end??
Re: OnPlayerUpdate causing errors... -
Ash. - 12.08.2010
- Everything that goes wrong is always something really small and annoying i guess?
- Thanks everyone