OnPlayerUpdate causing errors...
#1

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

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

Because you're returning 0 at the end of the code, which stops the syncronisation of the player.
Reply
#4

i think it's your return 0 at the end??
Reply
#5

- Everything that goes wrong is always something really small and annoying i guess?

- Thanks everyone
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)