Hello There, Guest! Login or Register


Useful Functions/Snippets/Commands
#2
Lock + Unlock

Code:
    if (strcmp(cmdtext, "/lock", true)==0)
    {
        if(IsPlayerInAnyVehicle(playerid))
        {
            new State=GetPlayerState(playerid);
            if(State!=PLAYER_STATE_DRIVER)
            {
                SendClientMessage(playerid,COLOR_RED,"You must be the driver to lock your vechicle!");
                return 1;
            }
            new i;
            for(i=0;i<MAX_PLAYERS;i++)
            {
                if(i != playerid)
                {
                    SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 1);
                }
            }
            SendClientMessage(playerid, COLOR_ORANGE, "Vehicle locked!");
            new Float:pX, Float:pY, Float:pZ;
            GetPlayerPos(playerid,pX,pY,pZ);
            PlayerPlaySound(playerid,1056,pX,pY,pZ);
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED, "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,COLOR_RED,"You must be the driver of the vechicle to unlock!");
                return 1;
            }
            new i;
            for(i=0;i<MAX_PLAYERS;i++)
            {
                SetVehicleParamsForPlayer(GetPlayerVehicleID(playerid),i, 0, 0);
            }
            SendClientMessage(playerid, COLOR_ORANGE, "Vehicle unlocked!");
            new Float:pX, Float:pY, Float:pZ;
            GetPlayerPos(playerid,pX,pY,pZ);
            PlayerPlaySound(playerid,1057,pX,pY,pZ);
        }
        else
        {
            SendClientMessage(playerid, COLOR_RED, "You're not in a vehicle!");
        }
        return 1;
    }

Vehicle [ Id ] ( Id's can be found on sa-mp wiki ) ( Do not type in a invalid id it will crash server, altough i could just do a invalid comment if id is incorrect ) ( rcon command )

Code:
    if(IsPlayerAdmin(playerid))
    {
        if(!strcmp(cmd, "/v", true))
        {
            new str[256], Float:x, Float:y, Float:z, id, tmp[256];
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "Correct Usage: /v [id]");
            id = strval(tmp);
            GetPlayerPos(playerid, x, y, z);
            CreateVehicle(id, x+2, y, z, 0, -1, -1, -1);
            format(str, 256, "Got vehicle: %d", id);
            SendClientMessage(playerid, COLOR_ORANGE, str);
            return true;
        }
    }

Reply


Messages In This Thread
Useful Functions/Snippets/Commands - by Jay - 04-21-2008, 03:19 PM
Re: Useful Functions/Snippets/Commands - by FarePak - 04-21-2008, 05:03 PM
Re: Useful Functions/Snippets/Commands - by Jay - 04-21-2008, 07:42 PM
Re: Useful Functions/Snippets/Commands - by Smoke - 04-23-2008, 06:50 AM
Re: Useful Functions/Snippets/Commands - by Jay - 04-23-2008, 04:54 PM
Re: Useful Functions/Snippets/Commands - by Smoke - 04-24-2008, 10:18 AM
Re: Useful Functions/Snippets/Commands - by Jay - 04-29-2008, 01:03 PM
Re: Useful Functions/Snippets/Commands - by Jay - 05-08-2008, 11:54 AM
Re: Useful Functions/Snippets/Commands - by Jay - 02-02-2009, 10:17 PM