Locking a car?
#1

How do I lock a car? I've tried to do it from the SAMP wiki and i keep on getting errorss.. even if i re applied the function in the OnVehicleStreamIn..

Someone help me here please?
Reply
#2

May this help you much

https://sampforum.blast.hk/showthread.php?tid=246878


https://sampwiki.blast.hk/wiki/SetVehicleParamsForPlayer - Direct wiki samp help

If not tell me , i will explain
Reply
#3

Quote:
Originally Posted by Neo Karls
View Post
May this help you much

https://sampforum.blast.hk/showthread.php?tid=246878


https://sampwiki.blast.hk/wiki/SetVehicleParamsForPlayer - Direct wiki samp help

If not tell me , i will explain
I've tried from the wiki, and I dont want to add more filterscripts because my server starts getting stuffed...
How do I make a command for locking it?
Reply
#4

Not sure is it working or not, try this

If yes, tell me


add the below lines to the
public OnPlayerCommandText(playerid, cmdtext[]) seen on your gamemode

pawn Code:
{
    if (strcmp(cmdtext, "/lock", true)==0)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new State=GetPlayerState(playerid);
        if(State!=PLAYER_STATE_DRIVER)
        {
            SendClientMessage(playerid,0xFF004040,"You can only lock the doors as the driver.");
            return 1;
        }
        new i;
        for(i=0;i<MAX_PLAYERS;i++)
        {
            if(i != playerid)
            {
                SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1);
            }
        }
        SendClientMessage(playerid, 0x33AA33AA, "Vehicle locked!");
        new Float:pX, Float:pY, Float:pZ;
        GetPlayerPos(playerid,pX,pY,pZ);
        PlayerPlaySound(playerid,1056,pX,pY,pZ);
    }
    else
    {
    SendClientMessage(playerid, 0xFF004040, "You're not in a vehicle!");
    }
    return 1;
}
    if (strcmp(cmdtext, "/unlock", true)==0)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new State=GetPlayerState(playerid);
        if(State!=PLAYER_STATE_DRIVER)
        {
            SendClientMessage(playerid,0xFF004040,"You can only unlock the doors as the driver.");
            return 1;
        }
        new i;
        for(i=0;i<MAX_PLAYERS;i++)
        {
            SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 0);
        }
        SendClientMessage(playerid, 0x33AA33AA, "Vehicle unlocked!");
        new Float:pX, Float:pY, Float:pZ;
        GetPlayerPos(playerid,pX,pY,pZ);
        PlayerPlaySound(playerid,1057,pX,pY,pZ);
    }
    else
    {
    SendClientMessage(playerid, 0xFF004040, "You're not in a vehicle!");
    }
    return 1;
}
    return 0;
}
Reply
#5

Hey you already posted this https://sampforum.blast.hk/showthread.php?tid=348133
Reply
#6

Quote:
Originally Posted by Neo Karls
View Post
Not sure is it working or not, try this

If yes, tell me


add the below lines to the
public OnPlayerCommandText(playerid, cmdtext[]) seen on your gamemode

pawn Code:
{
    if (strcmp(cmdtext, "/lock", true)==0)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new State=GetPlayerState(playerid);
        if(State!=PLAYER_STATE_DRIVER)
        {
            SendClientMessage(playerid,0xFF004040,"You can only lock the doors as the driver.");
            return 1;
        }
        new i;
        for(i=0;i<MAX_PLAYERS;i++)
        {
            if(i != playerid)
            {
                SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1);
            }
        }
        SendClientMessage(playerid, 0x33AA33AA, "Vehicle locked!");
        new Float:pX, Float:pY, Float:pZ;
        GetPlayerPos(playerid,pX,pY,pZ);
        PlayerPlaySound(playerid,1056,pX,pY,pZ);
    }
    else
    {
    SendClientMessage(playerid, 0xFF004040, "You're not in a vehicle!");
    }
    return 1;
}
    if (strcmp(cmdtext, "/unlock", true)==0)
{
    if(IsPlayerInAnyVehicle(playerid))
    {
        new State=GetPlayerState(playerid);
        if(State!=PLAYER_STATE_DRIVER)
        {
            SendClientMessage(playerid,0xFF004040,"You can only unlock the doors as the driver.");
            return 1;
        }
        new i;
        for(i=0;i<MAX_PLAYERS;i++)
        {
            SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 0);
        }
        SendClientMessage(playerid, 0x33AA33AA, "Vehicle unlocked!");
        new Float:pX, Float:pY, Float:pZ;
        GetPlayerPos(playerid,pX,pY,pZ);
        PlayerPlaySound(playerid,1057,pX,pY,pZ);
    }
    else
    {
    SendClientMessage(playerid, 0xFF004040, "You're not in a vehicle!");
    }
    return 1;
}
    return 0;
}
I got 26 errors, o.O
Reply
#7

Paste them here.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)