/createpvehicle help
#7

pawn Код:
CMD:createpvehicle(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 4)
    {
        SendClientMessage(playerid, COLOR_GREY, "You're not allowed to use this command.");
        return true;
    }
    if(AdminDuty[playerid] != 1 && PlayerInfo[playerid][pAdmin] < 5)
    {
        SendClientMessage(playerid,COLOR_WHITE, "You're not on-duty as admin. To access your admin commands you must be on-duty. Type /aduty to go on-duty.");
        return true;
    }
    new string[128], giveplayerid, modelid, color1, color2;
    if(sscanf(params, "uddd", giveplayerid, modelid, color1, color2)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /createpvehicle [playerid/partofname] [modelid] [color 1] [color 2]");

    if(AdminDuty[giveplayerid] == 1)
    {
        SendClientMessage(playerid,COLOR_WHITE, "You can't use that command on an on-duty admin.");
        return true;
    }

    if(color1 < 0 || color1 > 255) { SendClientMessage(playerid, COLOR_GREY, "   Color Number can't be below 0 or above 255!"); return true; }
    if(color2 < 0 || color2 > 255) { SendClientMessage(playerid, COLOR_GREY, "   Color Number can't be below 0 or above 255!"); return true; }
    if(modelid < 400 || modelid > 611) { SendClientMessage(playerid, COLOR_GREY, "   Vehicle Number can't be below 400 or above 611!"); return true; }
    new playervehicleid = GetPlayerFreeVehicleId(giveplayerid),
        totalvehicles = GetPlayerVehicleCountEx(giveplayerid);

    if(PlayerInfo[giveplayerid][pDonator] == 0 && totalvehicles >= 5) //PlayerInfo[giveplayerid][pTempDonator] > 0) && carsamount >= 5)
    {
        SendClientMessage(playerid, COLOR_GREY, "That player can't have more cars, non-donator can only own 5 cars.");
        return true;
    }
    if(PlayerInfo[giveplayerid][pDonator] == 1 && totalvehicles >= 7)
    {
        SendClientMessage(playerid, COLOR_GREY, "That player can't have more cars, Ruby Donator can only own 7 cars.");
        return true;
    }
    if(PlayerInfo[giveplayerid][pDonator] == 2 && totalvehicles >= 8)
    {
        SendClientMessage(playerid, COLOR_GREY, "That player can't have more cars, Sapphire Donator can only own 8 cars.");
        return true;
    }
    if(PlayerInfo[giveplayerid][pDonator] == 3 && totalvehicles >= 10)
    {
        SendClientMessage(playerid, COLOR_GREY, "That player can't have more cars, Diamond Donator can only own 10 cars.");
        return true;
    }

    if(playervehicleid == -1) return SendClientMessage(playerid, COLOR_GREY, "ERROR: That player can't have more cars.");
    if(PlayerInfo[giveplayerid][pDonator] == 0 && VehicleSpawned[giveplayerid] > 0)
    {
        SendClientMessage(playerid, COLOR_GREY, "That player is non-donator and can only have 1 vehicle spawned. The player must store that vehicle in order to create a new one.");
        return true;
    }
    if(PlayerInfo[giveplayerid][pDonator] == 1 && VehicleSpawned[giveplayerid] > 1)
    {
        SendClientMessage(playerid, COLOR_GREY, "That player is Ruby Donator and can only have 2 vehicles spawned. The player must store that vehicle in order to create a new one.");
        return true;
    }
    if(PlayerInfo[giveplayerid][pDonator] == 2 && VehicleSpawned[giveplayerid] > 2)
    {
        SendClientMessage(playerid, COLOR_GREY, "That player is Sapphire Donator and can only have 3 vehicles spawned. The player must store a vehicle in order to create a new one.");
        return true;
    }
    if(PlayerInfo[giveplayerid][pDonator] == 3 && VehicleSpawned[giveplayerid] > 3)
    {
        SendClientMessage(playerid, COLOR_GREY, "That player is Diamond Donator and can only have 4 vehicles spawned. The player must store a vehicle in order to create a new one.");
        return true;
    }
    if(PlayerInfo[giveplayerid][pDonator] < 0 || PlayerInfo[giveplayerid][pDonator] > 3)
    {
        SendClientMessage(playerid, COLOR_GREY, "ERROR: That player has an invalid Donator level.");
        return true;
    }

    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(giveplayerid,X,Y,Z);
    new Float:Angle;
    GetPlayerFacingAngle(giveplayerid,Angle);
    new car = CreatePlayerVehicle(giveplayerid, playervehicleid, modelid, X, Y, Z, Angle, color1, color2, 0);
    if(car == INVALID_PLAYER_VEHICLE_ID)
    {
        SendClientMessage(playerid, COLOR_GREY, "ERROR: Something went wrong and the car didn't get created.");
    }
    else
    {
        format(string, sizeof(string), " Vehicle successfully created with ID %d.", car);
        SendClientMessage(playerid, COLOR_GRAD1, string);
    }

    format(string, sizeof(string), "%s has created a %s for %s (Color 1: %d | Color 2: %d).", GetPlayerNameEx(playerid), GetVehicleName(car), GetPlayerNameEx(giveplayerid), color1, color2);
    Log("logs/playervehicle.log", string);
    return true;
}
This one should work as I'm using it myself.
Reply


Messages In This Thread
/createpvehicle help - by PrinceOfPersia - 24.12.2013, 13:27
Re: /createpvehicle help - by Dawno - 24.12.2013, 13:30
Re: /createpvehicle help - by PrinceOfPersia - 24.12.2013, 13:36
Re: /createpvehicle help - by Dawno - 24.12.2013, 13:39
Re: /createpvehicle help - by PrinceOfPersia - 24.12.2013, 13:45
Re: /createpvehicle help - by PrinceOfPersia - 24.12.2013, 17:22
Re: /createpvehicle help - by stundje - 24.12.2013, 17:26
Re: /createpvehicle help - by Konstantinos - 24.12.2013, 17:30
Re: /createpvehicle help - by PrinceOfPersia - 24.12.2013, 17:44
Re: /createpvehicle help - by ViruZz - 24.12.2013, 17:47

Forum Jump:


Users browsing this thread: 2 Guest(s)