SA-MP Forums Archive
What is wrong with this fu**in' code?!!? :O - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: What is wrong with this fu**in' code?!!? :O (/showthread.php?tid=249521)



What is wrong with this fu**in' code?!!? :O - anant - 19.04.2011

Under OnPlayerEnterVehicle -
pawn Код:
else if(GetPlayerVehicleID(playerid) >= 1 && GetPlayerVehicleID(playerid) <= 9 || GetPlayerVehicleID(playerid) >= 135 && GetPlayerVehicleID(playerid) <= 154 || GetPlayerVehicleID(playerid) >= 194 && GetPlayerVehicleID(playerid) <= 196)
    {
        if(HireCar[playerid] == 299) { GameTextForPlayer(playerid,"This is a rental vehicle.~n~Use /rentcar to rent it,~n~for ~r~$500~r~",5000,3); }
    }
    else if(GetPlayerVehicleID(playerid) >= 112 && GetPlayerVehicleID(playerid) <= 130)
    {
        if(HireCar[playerid] == 299) { GameTextForPlayer(playerid,"This is a rental bike.~n~Use /rentbike to rent it,~n~for ~r~$100~r~",5000,3); }
    }
GameTextForPlayer DOES NOT WORK :S


Re: What is wrong with this fu**in' code?!!? :O - CrazyBlob - 19.04.2011

try this

Код:
if(GetPlayerVehicleID(playerid) >= 1 && GetPlayerVehicleID(playerid) <= 9 || GetPlayerVehicleID(playerid) >= 135 && GetPlayerVehicleID(playerid) <= 154 || GetPlayerVehicleID(playerid) >= 194 && GetPlayerVehicleID(playerid) <= 196)
    {
        if(HireCar[playerid] == 299) { GameTextForPlayer(playerid,"This is a rental vehicle.~n~Use /rentcar to rent it,~n~for ~r~$500~r~",5000,3); }
    }
    if(GetPlayerVehicleID(playerid) >= 112 && GetPlayerVehicleID(playerid) <= 130)
    {
        if(HireCar[playerid] == 299) { GameTextForPlayer(playerid,"This is a rental bike.~n~Use /rentbike to rent it,~n~for ~r~$100~r~",5000,3); }
    }



Re: What is wrong with this fu**in' code?!!? :O - Vince - 19.04.2011

When OnPlayerEnterVehicle is called, the player isn't in the vehicle yet, thus GetPlayerVehicleID will return 0. Though, it's a mystery to me why you use GetPlayerVehicleID, because OnPlayerEnterVehicle has a vehicleid parameter.


Re: What is wrong with this fu**in' code?!!? :O - anant - 19.04.2011

@CrazyBlob---Lol always if?
@vince - Any other place to use that?...


Re: What is wrong with this fu**in' code?!!? :O - Babul - 19.04.2011

i suggest you to use your vehicle checking in the https://sampwiki.blast.hk/wiki/OnPlayerStateChange ...
@ Vince: i didnt try yet, but could the OnPlayerEnterVehicle be useful for checking if someone wants to jack your car (assming you locked your car while being inside)?


Re: What is wrong with this fu**in' code?!!? :O - Vince - 19.04.2011

Use OnPlayerStateChange.
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER /* || newstate == PLAYER_STATE_PASSENGER */)
    {
        //stuff here
    }
    return 1;
}
@Babul: Yes, probably.


Re: What is wrong with this fu**in' code?!!? :O - anant - 19.04.2011

@All - Thanks for helping me out guys!
Be helping me pro's :P
Later