setvehicleparamsex problem
#1

pawn Код:
CMD:vlock(playerid)
{
    new engine, lights, alarm, doors, bonnet, boot, objective, string[96], vehicleid = GetPlayerVehicleID(playerid);
    GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
    for(new v; v < MAX_PLAYER_VEHICLES; v++) {
        if(IsPlayerInRangeOfPoint(playerid, 5.0, playerVehicles[playerid][v][cPos][0], playerVehicles[playerid][v][cPos][1], playerVehicles[playerid][v][cPos][2]) || GetPlayerState(playerid) == PLAYER_STATE_DRIVER && playerVehicles[playerid][v][cID] != INVALID_PLAYER_VEHICLE_ID) {
            if(doors == 0) {
                format(string, sizeof(string), "* %s has locked their vehicle.", GetPlayerNameEx(playerid));
                ProxDetector(20.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(vehicleid, engine, lights, alarm, 1, bonnet, boot, objective);
                SetVehicleParamsForPlayer(vehicleid, playerid, 1, 1);
                SendClientMessage(playerid, COLOR_LIGHTGREEN, "You have locked your vehicle! (/clock to unlock it)"); break;
            }
            else if(doors == 1) {
                format(string, sizeof(string), "* %s has unlocked their vehicle.", GetPlayerNameEx(playerid));
                ProxDetector(20.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(vehicleid, engine, lights, alarm, 0, bonnet, boot, objective);
                SetVehicleParamsForPlayer(vehicleid, playerid, 1, 0);
                SendClientMessage(playerid, COLOR_LIGHTGREEN, "You have unlocked your vehicle! (/clock to lock it)"); break;
            }
    else SendClientMessage(playerid, COLOR_GREY, "You are not near your vehicle!"); break;
        }
    }
    return 1;
}
Whenever I do /vlock it says I have locked the vehicle but if I do it again, it says I locked it again, it never says it's unlocked and also when it says I locked it, the car isn't actually locked?
Reply
#2

Um your not putting a 1 in ur veriable
After locked put
doors = 1;

pawn Код:
CMD:vlock(playerid)
{
    new engine, lights, alarm, doors, bonnet, boot, objective, string[96], vehicleid = GetPlayerVehicleID(playerid);
    GetVehicleParamsEx(GetPlayerVehicleID(playerid), engine, lights, alarm, doors, bonnet, boot, objective);
    for(new v; v < MAX_PLAYER_VEHICLES; v++) {
        if(IsPlayerInRangeOfPoint(playerid, 5.0, playerVehicles[playerid][v][cPos][0], playerVehicles[playerid][v][cPos][1], playerVehicles[playerid][v][cPos][2]) || GetPlayerState(playerid) == PLAYER_STATE_DRIVER && playerVehicles[playerid][v][cID] != INVALID_PLAYER_VEHICLE_ID) {
            if(doors == 0) {
                format(string, sizeof(string), "* %s has locked their vehicle.", GetPlayerNameEx(playerid));
                ProxDetector(20.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(vehicleid, engine, lights, alarm, 1, bonnet, boot, objective);
                SetVehicleParamsForPlayer(vehicleid, playerid, 1, 1);
                SendClientMessage(playerid, COLOR_LIGHTGREEN, "You have locked your vehicle! (/clock to unlock it)"); break;
                doors = 1;
            }
            else if(doors == 1) {
                format(string, sizeof(string), "* %s has unlocked their vehicle.", GetPlayerNameEx(playerid));
                ProxDetector(20.0, playerid, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(vehicleid, engine, lights, alarm, 0, bonnet, boot, objective);
                SetVehicleParamsForPlayer(vehicleid, playerid, 1, 0);
                SendClientMessage(playerid, COLOR_LIGHTGREEN, "You have unlocked your vehicle! (/clock to lock it)"); break;
                doors = 0;
            }
    else SendClientMessage(playerid, COLOR_GREY, "You are not near your vehicle!"); break;
        }
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by Buzzbomb
Посмотреть сообщение
Um your not putting a 1 in ur veriable
After locked put
doors = 1;
SetVehicleParamsEx(vehicleid, engine, lights, alarm, 1, bonnet, boot, objective);

I am.
Reply
#4

pawn Код:
if(doors == 1)
    {
        doors = 0;
        VehicleLock[id] = 0;
        GameTextForPlayer(playerid, "~g~doors unlocked", 3000, 6);
    }
    else
    {
        doors = 1;
        VehicleLock[id] = 1;
        GameTextForPlayer(playerid, "~r~doors locked", 3000, 6);
    }
rhis how i got it set on mine I couldnt seem to do it that way either but i did it this way and it worked
Reply
#5

if(doors == 0) { doors = 1;....
if(doors == 1) { doors = 0;....

Edit: buzzbomb said it faster
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)