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);
}
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, angle);
GetPlayerPos(position X, Y, Z);
GetPlayerFacingAngle(position, angle);
and what about sending the message (This player is not connected) ?
|
if(!IsPlayerConnected( position )) return SendClientMessage( playerid, -1, "Player not connected" );