key state change problem
#1

I have this under if "(newkeys & KEY_NO)" and when im pressing the key N nothing happens,its like this part of the script isn't even there

if(IsPlayerInAnyVehicle(playerid))
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new Float, Float:y, Float:z;
GetVehiclePos(RentedVehicle[playerid], Float, Float:y, Float:z);

if(IsPlayerInRangeOfPoint(playerid, Float:5, Float, Float:y, Float:z))
{
if(LockedVeh[RentedVehicle[playerid]] == 0)
{
LockedVeh[RentedVehicle[playerid]] = 1;
SendClientMessage(playerid, -1, "Locked");
}
else {
LockedVeh[RentedVehicle[playerid]] = 0;
SendClientMessage(playerid, -1, "Unlocked");
}
}
}
}
}
Reply
#2

Before getting onto your problem can I just share some tips and advice..

1. Use [ pawn ] tags. You have smileys in your code...
2. Indent your code so we can read it more easily.
3.
pawn Code:
if(IsPlayerInAnyVehicle(playerid))
{
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
Using both conditional statements is redundant. Just use the second one. If their state isn't driver they aren't in a vehicle, are they?

4.
pawn Code:
Float:5
That's just strange. Use 5.0.

5. Use bool: for true/false variables (LockedVeh).

6. Finally on to your actual problem:
Add debug messages after each conditional statement so you can visualise how the code is executing and where it is failing.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)