Lock faction cars help
#1

Well i created an /flock to lock the faction cars but there is a problem
When you are in the same faction it keeps saying You can't use this command whats the problem?
pawn Код:
CMD:flock(playerid, params[])
{
    new string[128], idx, lockdone;
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pFac] == 1) return SendClientMessage(playerid, COLOR_GREY, "You can't use that command.");
    if(GetPlayerVehicleID(playerid) == FacInfo[1][fCars])
    {
        new Float:vx, Float:vy, Float:vz;
        GetVehiclePos(GetPlayerVehicleID(playerid) == FacInfo[1][fCars], vx, vy, vz);
        if(IsPlayerInRangeOfPoint(playerid, 3, vx, vy, vz))
        {
            idx = GetPlayerVehicleID(playerid) == FacInfo[1][fCars];
            new engine, lights, alarm, doors, bonnet, boot, objective;
            GetVehicleParamsEx(idx, engine, lights, alarm, doors, bonnet, boot, objective);
            if(doors)
            {

                SetVehicleParamsEx(idx, engine, lights, alarm, 0, bonnet, boot, objective);
                LSPDcar[playerid] = 0;
                format(string, sizeof(string), "* %s takes out their vehicle keys and unlocks it.", RPN(playerid));
                SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GameTextForPlayer(playerid, "~g~Vehicle Unlocked", 3500, 3);
            }
            else
            {
                SetVehicleParamsEx(idx, engine, lights, alarm, 1, bonnet, boot, objective);
                LSPDcar[playerid] = 1;
                format(string, sizeof(string), "* %s takes out their vehicle keys and locks it.", RPN(playerid));
                SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GameTextForPlayer(playerid, "~r~Vehicle Locked", 3500, 3);
            }
            lockdone = 1;
            return 1;
        }
        GetVehiclePos(GetPlayerVehicleID(playerid) == FacInfo[1][fCars], vx, vy, vz);
        if(IsPlayerInRangeOfPoint(playerid, 3, vx, vy, vz))
        {
            idx = PlayerInfo[playerid][pVVeh];
            new engine, lights, alarm, doors, bonnet, boot, objective;
            GetVehicleParamsEx(idx, engine, lights, alarm, doors, bonnet, boot, objective);
            if(doors)
            {

                SetVehicleParamsEx(idx, engine, lights, alarm, 0, bonnet, boot, objective);
                LSPDcar[playerid] = 0;
                format(string, sizeof(string), "* %s takes out their vehicle keys and unlocks it.", RPN(playerid));
                SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GameTextForPlayer(playerid, "~g~Vehicle Unlocked", 3500, 3);
            }
            else
            {
                SetVehicleParamsEx(idx, engine, lights, alarm, 1, bonnet, boot, objective);
                LSPDcar[playerid] = 1;
                format(string, sizeof(string), "* %s takes out their vehicle keys and locks it.", RPN(playerid));
                SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GameTextForPlayer(playerid, "~r~Vehicle Locked", 3500, 3);
            }
            lockdone = 1;
        }
        return 1;
    }
    if(!lockdone)
    {
        SendClientMessage(playerid, COLOR_GREY, "You are not near something you can lock/unlock.");
    }
    return 1;
}
Reply
#2

You opened your line into saying if(Pfaction == 1) return SCM etc

That line indicates that if the player is in that faction show them that msg

You need to add a '!' to set it as a negative

Fixed Code:
Код:
CMD:flock(playerid, params[])
{
    new string[128], idx, lockdone;
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(!PlayerInfo[playerid][pFac] == 1) return SendClientMessage(playerid, COLOR_GREY, "You can't use that command.");
    if(GetPlayerVehicleID(playerid) == FacInfo[1][fCars])
    {
        new Float:vx, Float:vy, Float:vz;
        GetVehiclePos(GetPlayerVehicleID(playerid) == FacInfo[1][fCars], vx, vy, vz);
        if(IsPlayerInRangeOfPoint(playerid, 3, vx, vy, vz))
        {
            idx = GetPlayerVehicleID(playerid) == FacInfo[1][fCars];
            new engine, lights, alarm, doors, bonnet, boot, objective;
            GetVehicleParamsEx(idx, engine, lights, alarm, doors, bonnet, boot, objective);
            if(doors)
            {

                SetVehicleParamsEx(idx, engine, lights, alarm, 0, bonnet, boot, objective);
                LSPDcar[playerid] = 0;
                format(string, sizeof(string), "* %s takes out their vehicle keys and unlocks it.", RPN(playerid));
                SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GameTextForPlayer(playerid, "~g~Vehicle Unlocked", 3500, 3);
            }
            else
            {
                SetVehicleParamsEx(idx, engine, lights, alarm, 1, bonnet, boot, objective);
                LSPDcar[playerid] = 1;
                format(string, sizeof(string), "* %s takes out their vehicle keys and locks it.", RPN(playerid));
                SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GameTextForPlayer(playerid, "~r~Vehicle Locked", 3500, 3);
            }
            lockdone = 1;
            return 1;
        }
        GetVehiclePos(GetPlayerVehicleID(playerid) == FacInfo[1][fCars], vx, vy, vz);
        if(IsPlayerInRangeOfPoint(playerid, 3, vx, vy, vz))
        {
            idx = PlayerInfo[playerid][pVVeh];
            new engine, lights, alarm, doors, bonnet, boot, objective;
            GetVehicleParamsEx(idx, engine, lights, alarm, doors, bonnet, boot, objective);
            if(doors)
            {

                SetVehicleParamsEx(idx, engine, lights, alarm, 0, bonnet, boot, objective);
                LSPDcar[playerid] = 0;
                format(string, sizeof(string), "* %s takes out their vehicle keys and unlocks it.", RPN(playerid));
                SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GameTextForPlayer(playerid, "~g~Vehicle Unlocked", 3500, 3);
            }
            else
            {
                SetVehicleParamsEx(idx, engine, lights, alarm, 1, bonnet, boot, objective);
                LSPDcar[playerid] = 1;
                format(string, sizeof(string), "* %s takes out their vehicle keys and locks it.", RPN(playerid));
                SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GameTextForPlayer(playerid, "~r~Vehicle Locked", 3500, 3);
            }
            lockdone = 1;
        }
        return 1;
    }
    if(!lockdone)
    {
        SendClientMessage(playerid, COLOR_GREY, "You are not near something you can lock/unlock.");
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by Ciandlah
Посмотреть сообщение
You opened your line into saying if(Pfaction == 1) return SCM etc

That line indicates that if the player is in that faction show them that msg

You need to add a '!' to set it as a negative

Fixed Code:
Код:
CMD:flock(playerid, params[])
{
    new string[128], idx, lockdone;
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(!PlayerInfo[playerid][pFac] == 1) return SendClientMessage(playerid, COLOR_GREY, "You can't use that command.");
    if(GetPlayerVehicleID(playerid) == FacInfo[1][fCars])
    {
        new Float:vx, Float:vy, Float:vz;
        GetVehiclePos(GetPlayerVehicleID(playerid) == FacInfo[1][fCars], vx, vy, vz);
        if(IsPlayerInRangeOfPoint(playerid, 3, vx, vy, vz))
        {
            idx = GetPlayerVehicleID(playerid) == FacInfo[1][fCars];
            new engine, lights, alarm, doors, bonnet, boot, objective;
            GetVehicleParamsEx(idx, engine, lights, alarm, doors, bonnet, boot, objective);
            if(doors)
            {

                SetVehicleParamsEx(idx, engine, lights, alarm, 0, bonnet, boot, objective);
                LSPDcar[playerid] = 0;
                format(string, sizeof(string), "* %s takes out their vehicle keys and unlocks it.", RPN(playerid));
                SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GameTextForPlayer(playerid, "~g~Vehicle Unlocked", 3500, 3);
            }
            else
            {
                SetVehicleParamsEx(idx, engine, lights, alarm, 1, bonnet, boot, objective);
                LSPDcar[playerid] = 1;
                format(string, sizeof(string), "* %s takes out their vehicle keys and locks it.", RPN(playerid));
                SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GameTextForPlayer(playerid, "~r~Vehicle Locked", 3500, 3);
            }
            lockdone = 1;
            return 1;
        }
        GetVehiclePos(GetPlayerVehicleID(playerid) == FacInfo[1][fCars], vx, vy, vz);
        if(IsPlayerInRangeOfPoint(playerid, 3, vx, vy, vz))
        {
            idx = PlayerInfo[playerid][pVVeh];
            new engine, lights, alarm, doors, bonnet, boot, objective;
            GetVehicleParamsEx(idx, engine, lights, alarm, doors, bonnet, boot, objective);
            if(doors)
            {

                SetVehicleParamsEx(idx, engine, lights, alarm, 0, bonnet, boot, objective);
                LSPDcar[playerid] = 0;
                format(string, sizeof(string), "* %s takes out their vehicle keys and unlocks it.", RPN(playerid));
                SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GameTextForPlayer(playerid, "~g~Vehicle Unlocked", 3500, 3);
            }
            else
            {
                SetVehicleParamsEx(idx, engine, lights, alarm, 1, bonnet, boot, objective);
                LSPDcar[playerid] = 1;
                format(string, sizeof(string), "* %s takes out their vehicle keys and locks it.", RPN(playerid));
                SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                GameTextForPlayer(playerid, "~r~Vehicle Locked", 3500, 3);
            }
            lockdone = 1;
        }
        return 1;
    }
    if(!lockdone)
    {
        SendClientMessage(playerid, COLOR_GREY, "You are not near something you can lock/unlock.");
    }
    return 1;
}
Okay that works, but the new issue, its not finding the LSPD car in the front of you, it keeps saying you are not near somting that you can lock/unlock
Reply
#4

You could try increasing the range in " if(IsPlayerInRangeOfPoint(playerid, 3, vx, vy, vz)) "?
For me 4 means you have to stand right outside the front door for it to work, so 4-5 would maybe be better?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)