[HELP] Admins can /lock and /unlock any vehicle
#1

I'm starting a TDM server and it contains "whore" vehicles (Hydra, Hunter, Sea Sparrow and Tanks).

- I need admins to have the ability to enter any vehicle and do /lock and /unlock.
- I need the vehicle to STAY locked until any admin unlocks it.
- I also need there to be a text label on the vehicle which says "Vehicle locked by [ADMIN'S NAME HERE]"


I'm so new to this that a basic and quick explanation doesn't help. Linking me to SA:MP wiki doesn't help either. I just need someone to post the complete code and tell me exactly where to put it in my gamemode.

By the way, I actually learn more if someone does that rather than basic explanations and wiki linking because I first do research, experiment and then get stuck and confused. Once someone posts the code and tells me where to place it, I'm able to observe the code and the placement and match it up with where I became confused. So please don't think I just want someone to do it for me and that I'm not learning anything because its quite the contrary.
Reply
#2

Bro use the wiki or the tutorials on the Scripting Tutorials but I prefer Wiki,because you will learn more their but I would like to help you but we are the same Im a Noob Scripter but I'm not a Noob scripter now..
Reply
#3

Quote:
Originally Posted by Derek_Westbrook
Посмотреть сообщение
Bro use the wiki or the tutorials on the Scripting Tutorials but I prefer Wiki,because you will learn more their but I would like to help you but we are the same Im a Noob Scripter but I'm not a Noob scripter now..
As I already said, I tried researching (using wiki, ****** and the forum search) and still don't know exactly what to do.
Reply
#4

pawn Код:
new vehicle_id, Text3D:vehicle3Dtext;
new pname[MAX_PLAYER_NAME], string[26 + MAX_PLAYER_NAME];
public OnGameModeInit ( )
{
    GetPlayerName(playerid, pname, sizeof(pname));
    format(string, sizeof(string), "Vehicle locked by Admin %s", pname);
    vehicle3Dtext = Create3DTextLabel(string, 0xFF0000AA, 0.0, 0.0, 0.0, 50.0, 0, 1 );
}


if(strcmp(cmdtext, "/lock", true)==0)
{
    if(IsPlayerInAnyVehicle(playerid) && IsPlayerAdmin(playerid))
    {
        new State=GetPlayerState(playerid);
        if  (State!=PLAYER_STATE_DRIVER)
        {
            SendClientMessage(playerid,0xFFFF00AA,"You can only lock the doors as the driver.");
            return 1;
        }
        lockedCar[GetPlayerVehicleID(playerid)]=1;
        new i;
        for (i=0;i<MAX_PLAYERS;i++)
        {
            if(i != playerid)
            {
                SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1);
            }
        }
        Attach3DTextLabelToVehicle(vehicle3Dtext, GetPlayerVehicleID(playerid), 0.0, 0.0, 2.0);
        SendClientMessage(playerid, 0xFFFF00AA, "Vehicle locked!");
        new Float:pX, Float:pY, Float:pZ;
        GetPlayerPos(playerid,pX,pY,pZ);
        PlayerPlaySound(playerid,1056,pX,pY,pZ);
    }
    else
    {
        SendClientMessage(playerid, 0xFFFF00AA, "You're not in a vehicle!");
    }
    return 1;
}


if(strcmp(cmdtext, "/unlock", true)==0)
{
    if(IsPlayerInAnyVehicle(playerid) && IsPlayerAdmin(playerid))
    {
        new State=GetPlayerState(playerid);
        if(State!=PLAYER_STATE_DRIVER)
        {
            SendClientMessage(playerid,0xFFFF00AA,"You can only unlock the doors as the driver.");
            return 1;
        }
        new i;
        lockedCar[GetPlayerVehicleID(playerid)]=0;
        for (i=0;i<MAX_PLAYERS;i++)
        {
            SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 0);
        }
        Delete3DTextLabel(vehicle3Dtext);
        SendClientMessage(playerid, 0xFFFF00AA, "Vehicle unlocked!");
        new Float:pX, Float:pY, Float:pZ;
        GetPlayerPos(playerid,pX,pY,pZ);
        PlayerPlaySound(playerid,1057,pX,pY,pZ);
    }
    else
    {
        SendClientMessage(playerid, 0xFFFF00AA, "You're not in a vehicle!");
    }
    return 1;
}
Note: Code Isnt Tested
Reply
#5

Hi can someone tell me exactly how to add this code?

Theres already OnGameModeInit in the file. When I try to just place that code into the gamemode, the compiler crashes "Compiler stopped working"
Reply
#6

Wow this sure got buried fast.

Anybody?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)