/lock and /park
#1

i want to add /lock and /park .

Don't worry about buying the lock, i want every player to have it automatically. But, here's the car stuff i use.

pawn Код:
if(strcmp(cmd, "/car", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new x_nr[32];
            x_nr = strtok(cmdtext, idx);
            new veh = GetPlayerVehicleID(playerid);
            new engine,lights,alarm,doors,hood,trunk,objective;
            if(!strlen(x_nr))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /car [name]");
                SendClientMessage(playerid, COLOR_GRAD1, "Available names: Engine, Lights, Hood, Trunk");
                return 1;
            }
            if(strcmp(x_nr,"engine",true) == 0)
            {
                if(GetPVarInt(playerid, "Engine") == 0)
                {
                    GetPlayerVehicleID(playerid);
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,VEHICLE_PARAMS_ON,lights,alarm,doors,hood,trunk,objective);
                    SetPVarInt(playerid, "Engine", 1);
                }
                else if(GetPVarInt(playerid, "Engine") == 1)
                {
                    GetPlayerVehicleID(playerid);
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,VEHICLE_PARAMS_OFF,lights,alarm,doors,hood,trunk,objective);
                    SetPVarInt(playerid, "Engine", 0);
                }
                return 1;
            }
            if(strcmp(x_nr,"lights",true) == 0)
            {
                if(GetPVarInt(playerid, "Lights") == 0)
                {
                    GetPlayerVehicleID(playerid);
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,engine,VEHICLE_PARAMS_ON,alarm,doors,hood,trunk,objective);
                    SetPVarInt(playerid, "Lights", 1);
                }
                else if(GetPVarInt(playerid, "Lights") == 1)
                {
                    GetPlayerVehicleID(playerid);
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,engine,VEHICLE_PARAMS_OFF,alarm,doors,hood,trunk,objective);
                    SetPVarInt(playerid, "Lights", 0);
                }
                return 1;
            }
            if(strcmp(x_nr,"hood",true) == 0)
            {
                if(GetPVarInt(playerid, "Hood") == 0)
                {
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,engine,lights,alarm,doors,VEHICLE_PARAMS_ON,trunk,objective);
                    SetPVarInt(playerid, "Hood", 1);
                }
                else if(GetPVarInt(playerid, "Hood") == 1)
                {
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,engine,lights,alarm,doors,VEHICLE_PARAMS_OFF,trunk,objective);
                    SetPVarInt(playerid, "Hood", 0);
                }
                return 1;
            }
            if(strcmp(x_nr,"trunk",true) == 0)
            {
                if(GetPVarInt(playerid, "Trunk") == 0)
                {
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,VEHICLE_PARAMS_ON,objective);
                    SetPVarInt(playerid, "Trunk", 1);
                }
                else if(GetPVarInt(playerid, "Trunk") == 1)
                {
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,VEHICLE_PARAMS_OFF,objective);
                    SetPVarInt(playerid, "Trunk", 0);
                }
/car lock and /car park?

Thanks. Anyone who helps gets a reppo
Reply
#2

Nice command. Did you make that yourself?
Reply
#3

Yes, i made it for a friend and ended up using it,... Anyway, can anyone help?
Reply
#4

the lock command is easy ill make it now
Reply
#5

and park please, thanks.

GRR
This forum requires that you wait 120 seconds between posts. Please try again in 47 seconds.
Reply
#6

Quote:
Originally Posted by uprp
Посмотреть сообщение
Yes, i made it for a friend and ended up using it,... Anyway, can anyone help?
It looks fairly similar to the older version of NGRP...

Anyways... you should be able to check the SA-MP Wikipedia for more uses of the "SetVehicleParamsEx" function and create a lock function from there. As for the park command, that will differ from GM to GM.
Reply
#7

i dont know how to make /Park but here is a go at Lock

Код:
if(strcmp(cmd, "/car", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new x_nr[32];
            x_nr = strtok(cmdtext, idx);
            new veh = GetPlayerVehicleID(playerid);
            new engine,lights,alarm,doors,hood,trunk,objective;
            if(!strlen(x_nr))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /car [name]");
                SendClientMessage(playerid, COLOR_GRAD1, "Available names: Engine, Lights, Hood, Trunk");
                return 1;
            }
            if(strcmp(x_nr,"engine",true) == 0)
            {
                if(GetPVarInt(playerid, "Engine") == 0)
                {
                    GetPlayerVehicleID(playerid);
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,VEHICLE_PARAMS_ON,lights,alarm,doors,hood,trunk,objective);
                    SetPVarInt(playerid, "Engine", 1);
                }
                else if(GetPVarInt(playerid, "Engine") == 1)
                {
                    GetPlayerVehicleID(playerid);
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,VEHICLE_PARAMS_OFF,lights,alarm,doors,hood,trunk,objective);
                    SetPVarInt(playerid, "Engine", 0);
                }
                return 1;
            }
            if(strcmp(x_nr,"lights",true) == 0)
            {
                if(GetPVarInt(playerid, "Lights") == 0)
                {
                    GetPlayerVehicleID(playerid);
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,engine,VEHICLE_PARAMS_ON,alarm,doors,hood,trunk,objective);
                    SetPVarInt(playerid, "Lights", 1);
                }
                else if(GetPVarInt(playerid, "Lights") == 1)
                {
                    GetPlayerVehicleID(playerid);
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,engine,VEHICLE_PARAMS_OFF,alarm,doors,hood,trunk,objective);
                    SetPVarInt(playerid, "Lights", 0);
                }
                return 1;
            }
            if(strcmp(x_nr,"hood",true) == 0)
            {
                if(GetPVarInt(playerid, "Hood") == 0)
                {
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,engine,lights,alarm,doors,VEHICLE_PARAMS_ON,trunk,objective);
                    SetPVarInt(playerid, "Hood", 1);
                }
                else if(GetPVarInt(playerid, "Hood") == 1)
                {
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,engine,lights,alarm,doors,VEHICLE_PARAMS_OFF,trunk,objective);
                    SetPVarInt(playerid, "Hood", 0);
                }
                return 1;
            }
            if(strcmp(x_nr,"trunk",true) == 0)
            {
                if(GetPVarInt(playerid, "Trunk") == 0)
                {
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,VEHICLE_PARAMS_ON,objective);
                    SetPVarInt(playerid, "Trunk", 1);
                }
                else if(GetPVarInt(playerid, "Trunk") == 1)
                {
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,VEHICLE_PARAMS_OFF,objective);
                    SetPVarInt(playerid, "Trunk", 0);
                }
            }
            if(strcmp(x_nr,"lock",true) == 0)
			{
			    if(GetPVarInt(playerid, "Doors") == 0)
			    {
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,VEHICLE_PARAMS_ON,objective);
                    SetPVarInt(playerid, "Doors", 1);
				}
				else if(GetPVarInt(playerid, "Lock") == 1)
				{
				    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,VEHICLE_PARAMS_OFF,objective);
                    SetPVarInt(playerid, "Doors", 0);
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "   Invalid /car function !");
                return 1;
            }
        }
        return 1;
    }
UNTESTED But Should Work
Reply
#8

Just as a note...

Doing this:

pawn Код:
SetPVarInt(playerid, "Doors", 0);
Is a waste and can be very inefficient when using PVars. You are better off using "DeletePVar()" if you wish to set the value to 0.
Reply
#9

Quote:
Originally Posted by [Nuclear]Phoebe
Посмотреть сообщение
i dont know how to make /Park but here is a go at Lock

Код:
if(strcmp(cmd, "/car", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            new x_nr[32];
            x_nr = strtok(cmdtext, idx);
            new veh = GetPlayerVehicleID(playerid);
            new engine,lights,alarm,doors,hood,trunk,objective;
            if(!strlen(x_nr))
            {
                SendClientMessage(playerid, COLOR_WHITE, "USAGE: /car [name]");
                SendClientMessage(playerid, COLOR_GRAD1, "Available names: Engine, Lights, Hood, Trunk");
                return 1;
            }
            if(strcmp(x_nr,"engine",true) == 0)
            {
                if(GetPVarInt(playerid, "Engine") == 0)
                {
                    GetPlayerVehicleID(playerid);
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,VEHICLE_PARAMS_ON,lights,alarm,doors,hood,trunk,objective);
                    SetPVarInt(playerid, "Engine", 1);
                }
                else if(GetPVarInt(playerid, "Engine") == 1)
                {
                    GetPlayerVehicleID(playerid);
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,VEHICLE_PARAMS_OFF,lights,alarm,doors,hood,trunk,objective);
                    SetPVarInt(playerid, "Engine", 0);
                }
                return 1;
            }
            if(strcmp(x_nr,"lights",true) == 0)
            {
                if(GetPVarInt(playerid, "Lights") == 0)
                {
                    GetPlayerVehicleID(playerid);
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,engine,VEHICLE_PARAMS_ON,alarm,doors,hood,trunk,objective);
                    SetPVarInt(playerid, "Lights", 1);
                }
                else if(GetPVarInt(playerid, "Lights") == 1)
                {
                    GetPlayerVehicleID(playerid);
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,engine,VEHICLE_PARAMS_OFF,alarm,doors,hood,trunk,objective);
                    SetPVarInt(playerid, "Lights", 0);
                }
                return 1;
            }
            if(strcmp(x_nr,"hood",true) == 0)
            {
                if(GetPVarInt(playerid, "Hood") == 0)
                {
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,engine,lights,alarm,doors,VEHICLE_PARAMS_ON,trunk,objective);
                    SetPVarInt(playerid, "Hood", 1);
                }
                else if(GetPVarInt(playerid, "Hood") == 1)
                {
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,engine,lights,alarm,doors,VEHICLE_PARAMS_OFF,trunk,objective);
                    SetPVarInt(playerid, "Hood", 0);
                }
                return 1;
            }
            if(strcmp(x_nr,"trunk",true) == 0)
            {
                if(GetPVarInt(playerid, "Trunk") == 0)
                {
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,VEHICLE_PARAMS_ON,objective);
                    SetPVarInt(playerid, "Trunk", 1);
                }
                else if(GetPVarInt(playerid, "Trunk") == 1)
                {
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,VEHICLE_PARAMS_OFF,objective);
                    SetPVarInt(playerid, "Trunk", 0);
                }
            }
            if(strcmp(x_nr,"lock",true) == 0)
			{
			    if(GetPVarInt(playerid, "Doors") == 0)
			    {
                    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,VEHICLE_PARAMS_ON,objective);
                    SetPVarInt(playerid, "Doors", 1);
				}
				else if(GetPVarInt(playerid, "Lock") == 1)
				{
				    GetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,trunk,objective);
                    SetVehicleParamsEx(veh,engine,lights,alarm,doors,hood,VEHICLE_PARAMS_OFF,objective);
                    SetPVarInt(playerid, "Doors", 0);
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "   Invalid /car function !");
                return 1;
            }
        }
        return 1;
    }
UNTESTED But Should Work
Should i add unlock?
Reply
#10

your choice the lock locks and unlocks in wat i did
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)