Admins Vehicles .
#1

hey guys , its been awhile i didnt scripting cause of a big exam .. hha

i need help with this .

i'm making an admincar cmd and its works pretty great lolz.
but i want the car just can be drive by an Admin, if a normal player/not admin he cant drive it !

list of the car id's

pawn Код:
444, 556, 557, 494, 502, 503, 520, 432
can someone help me ? im getting problems here.
Reply
#2

pawn Код:
new admincar0
new admincar1
new admincar2
new admincar3
new admincar4
new admincar5
new admincar6
new admincar7
pawn Код:
//ongamemodeinit                      
admincar1 = AddStaticVehicleEx(431//id,-2186.94200000,-424.17260000,35.33594000,90.00000000,-1,-1,900); //Bus u can change it with the first nummber near Ex
OnPlayerEnter
[PAWN]
//U admin like rcon

IsPlayerAdmin

GetVehicleModel ids));
SendClientMessage:This car is only for Admins!
Reply
#3

okay , thanks let me try
Reply
#4

You can use this
https://sampforum.blast.hk/showthread.php?tid=160810
or
try my way
ZCMD + SSCANF2 + foreach
pawn Код:
#define MAX_CUSTOM_VEHICLES 50
new cVeh[MAX_CUSTOM_VEHICLES];

CMD:veh(playerid, params[])
{
    new id, Float:pos[4], col[2];
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Admin Only");
    if(!strcmp(params, "destroy"))
    {
        if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You must be inside a vehicle to destroy it.");
        for(new i=0; i<MAX_CUSTOM_VEHICLES; i++)
        {
            if(GetPlayerVehicleID(playerid) == cVeh[i])
            {
                DestroyVehicle(cVeh[i]);
                i = MAX_CUSTOM_VEHICLES;
                return 1;
            }
        }
        SendClientMessage(playerid, COLOR_GREY, "You can't destroy this vehicle.");
        return 1;
    }
    if(sscanf(params, "iii", id, col[0], col[1])) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /veh [vehicleid/destroy] [color1] [color2]");
    if(id < 400 || id > 611) return SendClientMessage(playerid, COLOR_GREY, "Vehicles are between 400 and 611.");
    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
    GetPlayerFacingAngle(playerid, pos[3]);
    for(new i=0; i<MAX_CUSTOM_VEHICLES; i++)
    {
        if(!cVeh[i])
        {
            cVeh[i] = CreateVehicle(id, pos[0], pos[1], pos[2], pos[3], col[0], col[1], 1200);
            PutPlayerInVehicle(playerid,cVeh[i],1);
            i = MAX_CUSTOM_VEHICLES;
        }
    }
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == 2)
    {
        new CarCheck = GetPlayerVehicleID(playerid);
        for(new i=0; i<MAX_CUSTOM_VEHICLES; i++)
        if(CarCheck == cVeh[i] )
        {
            if(!IsPlayerAdmin(playerid))
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, -1, "Admin Car, Please Exit");
                return 1;
            }
        }
        return 1;
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by Glad2BeHere
Посмотреть сообщение
You can use this
https://sampforum.blast.hk/showthread.php?tid=160810
or
try my way
ZCMD + SSCANF2 + foreach
pawn Код:
#define MAX_CUSTOM_VEHICLES 50
new cVeh[MAX_CUSTOM_VEHICLES];

CMD:veh(playerid, params[])
{
    new id, Float:pos[4], col[2];
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "Admin Only");
    if(!strcmp(params, "destroy"))
    {
        if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid, COLOR_GREY, "You must be inside a vehicle to destroy it.");
        for(new i=0; i<MAX_CUSTOM_VEHICLES; i++)
        {
            if(GetPlayerVehicleID(playerid) == cVeh[i])
            {
                DestroyVehicle(cVeh[i]);
                i = MAX_CUSTOM_VEHICLES;
                return 1;
            }
        }
        SendClientMessage(playerid, COLOR_GREY, "You can't destroy this vehicle.");
        return 1;
    }
    if(sscanf(params, "iii", id, col[0], col[1])) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /veh [vehicleid/destroy] [color1] [color2]");
    if(id < 400 || id > 611) return SendClientMessage(playerid, COLOR_GREY, "Vehicles are between 400 and 611.");
    GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
    GetPlayerFacingAngle(playerid, pos[3]);
    for(new i=0; i<MAX_CUSTOM_VEHICLES; i++)
    {
        if(!cVeh[i])
        {
            cVeh[i] = CreateVehicle(id, pos[0], pos[1], pos[2], pos[3], col[0], col[1], 1200);
            PutPlayerInVehicle(playerid,cVeh[i],1);
            i = MAX_CUSTOM_VEHICLES;
        }
    }
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == 2)
    {
        new CarCheck = GetPlayerVehicleID(playerid);
        for(new i=0; i<MAX_CUSTOM_VEHICLES; i++)
        if(CarCheck == cVeh[i] )
        {
            if(!IsPlayerAdmin(playerid))
            {
                RemovePlayerFromVehicle(playerid);
                SendClientMessage(playerid, -1, "Admin Car, Please Exit");
                return 1;
            }
        }
        return 1;
    }
    return 1;
}
let me try
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)