OnPlayerStateChange
#1

Hey guys,
Im having problems with the callback OnPlayerStateChange. Im trying to check that the newstate == driver, and the oldstate == onfoot, and then show him a textdraw. Somehow it doesnt work, but in game it shows its changing.

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new string[39];
    format(string, sizeof(string), "You changed from state %d to state %d!", oldstate, newstate);
    SendClientMessage(playerid,0xFFFFFFFF,string);
    if( oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT )
    {
   
        TextDrawHideForPlayer(playerid, Speedo[playerid]);
    }
    if( oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER )
    {
        TextDrawShowForPlayer(playerid, Speedo[playerid]);
    }
    return 1;
}
It shows "You changed from state %d to state %d!" in game, with the %d with a number ofcourse.
Anyone knows what the problem is?
Reply
#2

pawn Код:
if(newstate == PLAYER_STATE_ONFOOT )
        {
   
        TextDrawHideForPlayer(playerid, Speedo[playerid]);
    }
    if(newstate == PLAYER_STATE_DRIVER )
    {
        TextDrawShowForPlayer(playerid, Speedo[playerid]);
    }
    return 1;
}
try this hope it works for you
Reply
#3

I just debugged all of it, and i found out its skipping one line.
"vehicleid = GetPlayerVehicleID(playerid);".
I do have new vehicle; above it.
Reply
#4

did you used
pawn Код:
new vehicleid = GetPlayerVehicleID(playerid);
.
Reply
#5

pawn Код:
new vehicleid;
vehicleid = GetPlayerVehicleID(playerid); // it skips this line, and just continues the things that are down this
Reply
#6

Quote:
Originally Posted by Wesley221
Посмотреть сообщение
pawn Код:
new vehicleid;
vehicleid = GetPlayerVehicleID(playerid); // it skips this line, and just continues the things that are down this
try
pawn Код:
new vehicleid = GetPlayerVehicleID(playerid);
Reply
#7

I did that and still was the same
Reply
#8

Then in the place vehicleid in your script use GetPlayerVehicleID(playerid);
Example:
pawn Код:
if(GetPlayerVehicleID == watever car)
Reply
#9

Removed... just looked and saw my error
Reply
#10

Now it skips "TextDrawSetSTring()" and "TextDrawShowForPlayer();.

pawn Код:
TextDrawSetString(Speedo[playerid], Vehstring);
TextDrawShowForPlayer(playerid, Speedo[playerid]);
I did format the Vehstring, dont worry about that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)