OnPlayerStateChange not working at all!
#1

OnPlayerStateChange not working at all for me .. i tried many things like changing return 0 to return 1 and did stuff like that but it didnt helped..

Yes i will +Rep you

the Code:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{

if(newstate == PLAYER_STATE_DRIVER)
{
SetPlayerArmedWeapon(playerid, 0);
return 0;
}
if ( GetVehicleModel ( GetPlayerVehicleID ( playerid ) ) == 425 && gClass[playerid] == PILOT_CLASS)
{
SendClientMessage(playerid, RED,"ERROR: You need to be Pilot to drive Hunter");
RemovePlayerFromVehicle(playerid);
return 0;
}
if ( GetVehicleModel ( GetPlayerVehicleID ( playerid ) ) == 520 && gClass[playerid] == PILOT_CLASS)
{

SendClientMessage(playerid, RED,"ERROR: You need to be Pilot to drive Hydra");
RemovePlayerFromVehicle(playerid);
return 0;
}
if ( GetVehicleModel ( GetPlayerVehicleID ( playerid ) ) == 432 && gClass[playerid] == ENGINEER_CLASS)
{
SendClientMessage(playerid, RED,"ERROR: You need to be Engineer to drive Rhino");
RemovePlayerFromVehicle(playerid);
return 0;
}

if (GetVehicleModel(GetPlayerVehicleID ( playerid ) ) == 447 && gClass[playerid] == PILOT_CLASS)
{
SendClientMessage(playerid, RED,"ERROR: You need to be Pilot to drive Sea-Sparrow");
RemovePlayerFromVehicle(playerid);
}
return 0;
}
and please be fast as i got less time :/
Reply
#2

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{

if(newstate == PLAYER_STATE_DRIVER)
{
SetPlayerArmedWeapon(playerid, 0);
if ( GetVehicleModel ( GetPlayerVehicleID ( playerid ) ) == 425 && gClass[playerid] == PILOT_CLASS)
{
SendClientMessage(playerid, RED,"ERROR: You need to be Pilot to drive Hunter");
RemovePlayerFromVehicle(playerid);
return 0;
}
if ( GetVehicleModel ( GetPlayerVehicleID ( playerid ) ) == 520 && gClass[playerid] == PILOT_CLASS)
{

SendClientMessage(playerid, RED,"ERROR: You need to be Pilot to drive Hydra");
RemovePlayerFromVehicle(playerid);
return 0;
}
if ( GetVehicleModel ( GetPlayerVehicleID ( playerid ) ) == 432 && gClass[playerid] == ENGINEER_CLASS)
{
SendClientMessage(playerid, RED,"ERROR: You need to be Engineer to drive Rhino");
RemovePlayerFromVehicle(playerid);
return 0;
}

if (GetVehicleModel(GetPlayerVehicleID ( playerid ) ) == 447 && gClass[playerid] == PILOT_CLASS)
{
SendClientMessage(playerid, RED,"ERROR: You need to be Pilot to drive Sea-Sparrow");
RemovePlayerFromVehicle(playerid);
}
return 0;
}
return 0;
}
should work: btw, no difference between return 0 and return 1 in OnPlayerStateChange , because that callback doesnt handle returns.
Reply
#3

Nothing Happened Bro.. when i sit in it, nothing just happens :/
Reply
#4

Bump Please Help anyone :/
Reply
#5

it shouldnt return 0 in everything
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{

if(newstate == PLAYER_STATE_DRIVER)
{
SetPlayerArmedWeapon(playerid, 0);
}
if ( GetVehicleModel ( GetPlayerVehicleID ( playerid ) ) == 425 && gClass[playerid] == PILOT_CLASS)
{
SendClientMessage(playerid, RED,"ERROR: You need to be Pilot to drive Hunter");
RemovePlayerFromVehicle(playerid);
}
if ( GetVehicleModel ( GetPlayerVehicleID ( playerid ) ) == 520 && gClass[playerid] == PILOT_CLASS)
{

SendClientMessage(playerid, RED,"ERROR: You need to be Pilot to drive Hydra");
RemovePlayerFromVehicle(playerid);
}
if ( GetVehicleModel ( GetPlayerVehicleID ( playerid ) ) == 432 && gClass[playerid] == ENGINEER_CLASS)
{
SendClientMessage(playerid, RED,"ERROR: You need to be Engineer to drive Rhino");
RemovePlayerFromVehicle(playerid);
}

if (GetVehicleModel(GetPlayerVehicleID ( playerid ) ) == 447 && gClass[playerid] == PILOT_CLASS)
{
SendClientMessage(playerid, RED,"ERROR: You need to be Pilot to drive Sea-Sparrow");
RemovePlayerFromVehicle(playerid);
}
return 0;
}
Should work...

Edit : I made a mistake , edited
Reply
#6

didint worked.. i already told u, i did my best.. :/ please help
Reply
#7

did you try debugging ?
Reply
#8

whats that?
Reply
#9

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate) zijn, etc.
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new vModel = GetVehicleModel(GetPlayerVehicleID(playerid));
        if((vModel == 432 && GetPlayerScore(playerid) < 500) || (vModel == 520 && GetPlayerScore(playerid) < 500))
        {
            RemovePlayerFromVehicle(playerid);
            SendClientMessage(playerid, -1, "You can't enter this Vehicle yet check /vehicles for the rank needed to enter this vehicle!");
        }
    }
    return 1;
}
This will work just edit it to what you want
Reply
#10

what if
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate) zijn, etc.
{
    if(newstate == PLAYER_STATE_DRIVER)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        if(vehicleid == 444) return //...
        else if(vehicleid ==445) return //...
    }
    return 1;
}
Use Else If !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)