/givevipcar command [HELP +Rep !!Fast if possible]
#1

Sup guys Last day i made this cmd with a little help from a Forum user but the command wont give the car to specificed Playerid
example i type /givecar 1 550 128 128 0
The player (admin) who use cmds car spaw for him
Not for the playerid they chose

/givevipcar [playerid] [model] [color1] [color2] [price]
pawn Код:
CMD:givevipcar(playerid, params[])
{
    if(!IsAdmin(playerid, 1)) return SendClientMessage(playerid, COLOR_RED, "You are not admin!");
    if(!IsPlayerSpawned(playerid)) return SendClientMessage(playerid, COLOR_RED, "You can't use this command now!");

    new
        position,
        modelid,
        color1,
        color2,
        price;

    if(sscanf(params, "dk<vehicle>ddd", position,modelid, color1, color2, price)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /givevipcar [playerid] [model] [color1] [color2] [price]");
    if(!(400 <= modelid <= 611)) return SendClientMessage(playerid, COLOR_RED, "Invalid model ID!");
    if(color1 < 0 || color2 < 0) return SendClientMessage(playerid, COLOR_RED, "Invalid color!");
    if(price < 0) return SendClientMessage(playerid, COLOR_RED, "Invalid price!");

    new
        Float:X,
        Float:Y,
        Float:Z,
        Float:angle;
    new freeid = GetFreeVehicleID();
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerFacingAngle(playerid, angle);

    X += floatmul(floatsin(-angle, degrees), 4.0);
    Y += floatmul(floatcos(-angle, degrees), 4.0);

    new
        i = 1;

    for(; i < MAX_DVEHICLES; i++)
        if(!VehicleCreated[i]) break;

    if(i == MAX_DVEHICLES) return SendClientMessage(playerid, COLOR_RED, "Can't add any more vehicles!");

    VehicleCreated[i] = VEHICLE_PLAYER;
    VehicleModel[i] = modelid;
    VehiclePos[i][0] = X;
    VehiclePos[i][1] = Y;
    VehiclePos[i][2] = Z;
    VehiclePos[i][3] = angle+90.0;
    VehicleColor[i][0] = color1;
    VehicleColor[i][1] = color2;
    VehicleInterior[i] = GetPlayerInterior(playerid);
    VehicleWorld[i] = GetPlayerVirtualWorld(playerid);
    VehicleValue[i] = price;
    GetPlayerName(playerid, VehicleOwner[freeid], sizeof(VehicleOwner[]));

    //valstr(VehicleOwner[i],position);
    VehicleNumberPlate[i] = DEFAULT_NUMBER_PLATE;

    for(new d=0; d < sizeof(VehicleTrunk[]); d++)
        VehicleTrunk[i][d][0] = 0, VehicleTrunk[i][d][1] = 0;

    for(new d=0; d < sizeof(VehicleMods[]); d++)
        VehicleMods[i][d] = 0;

    VehiclePaintjob[i] = 255;
    VehicleLock[i] = 0;
    VehicleAlarm[i] = 0;
    UpdateVehicle(i, 0);
    SaveVehicle(i);
    new
       msg[145];

    format(msg, sizeof(msg), "Added vehicle id %d to Player %s", i, position);
    return SendClientMessage(playerid, COLOR_YELLOW, msg);
}
Reply
#2

pawn Код:
GetPlayerPos(playerid, X, Y, Z);
    GetPlayerFacingAngle(playerid, angle);
There is your problem.
playerid is the player who sent the command, in that case, the admin. Change "playerid" to "position".
pawn Код:
GetPlayerPos(position X, Y, Z);
    GetPlayerFacingAngle(position, angle);
Reply
#3

and what about sending the message (This player is not connected) ?
Reply
#4

Quote:
Originally Posted by Toxik
Посмотреть сообщение
and what about sending the message (This player is not connected) ?
pawn Код:
if(!IsPlayerConnected( position )) return SendClientMessage( playerid, -1, "Player not connected" );
Reply
#5

can you tell me why is uded (position)) ?
Reply
#6

You told sscanf that position = the id of the player you want to give the car to.
Reply
#7

well the whole command is a Wrong system
can anyone fix it for me ?
i did /givecar blah blah blah alone in server
and what happened ?
did /givecar 0 550 128 128 0
and message said that i given a cat to PLayer : blah bla
and me is the owner
btw the System is AVS
if anyone can edit it for me +Repp 7 days in row
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)