ZCMD: /aveh [vehicle id] [color1] [color2] ???
#1

hey, I was wondering, how to make a /aveh command? like admin vehicle.

This is what I did:

pawn Код:
// ADMIN COMMNAD: aveh //

COMMAND:aveh(playerid, params[])
{
  if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFFFF, "{FFFFFF}SERVER: Unkown command.");
  new vehicle, color;
  if(sscanf(params, "uiii", vehicle, color)) return SendClientMessage(playerid, 0xFFFFFF, "{FFFFFF}Correct usage: /aveh [vehicle ID] [color1] [color2]");
  if(vehicle > 611 || vehicle < 400) return SendClientMessage(playerid, 0xFFFFFF, "Vehicle ID's: 400-611");
  if(color > 255 || color < 0) return SendClientMessage(playerid, 0xFFFFFF, "Car color ID's: 0-255");
  GetPlayerVehicleID(vehicle, color, color);
  return 1;
}
The problem here is that I can't spawn a vehicle. Everytime I do it shows "Vehicle ID's: 400-611"
Reply
#2

pawn Код:
if(sscanf(params, "uiii", vehicle, color))
why you defined uiii? you will just use ddd (car, color1, color2)
Reply
#3

pawn Код:
CMD:aveh(playerid, params[])
{
        if(!IsPlayerAdmin(playerid)) return 0; //same as that client message you made
    if(isnull(params)) return Usage(playerid, "/car [model]");

    new veh, col[2];
    new tmp[32],string[148];

    if(sscanf(params, "s[32]I(-1)I(-1)", tmp, col[0], col[1])) return SendClientMessage(playerid, COLOR_RED, "/aveh [model] [color] [color]");

    if(vehicle < 400 || vehicle > 611) return SendClientMessage(playerid,COLOR_RED, "vehcile IDs between 400 - 611!");
    if(col[0] || col[1] > 255 || col[0] || col[1]< 0) return SendClientMessage(playerid, 0xFFFFFF, "Car color ID's: 0-255");

    new Float:cPos[4];

    GetPlayerPos(playerid, cPos[0], cPos[1], cPos[2]);
    GetPlayerFacingAngle(playerid, cPos[3]);

    CreateVehicle(vehicle, cPos[0], cPos[1]-3, cPos[2], cPos[3], col[0], col[1], -1);
    return 1;
}
try that
Reply
#4

This command will work.
pawn Код:
CMD:aveh(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return 0;
    new type,color,color2,Float:cPos[4];
    if(sscanf(params, "iii", type,color,color2) return SendClientMessage(playerid, COLOR_RED, "/aveh [model] [color] [color]");
    if(type < 400 || type > 611) return SendClientMessage(playerid,COLOR_RED, "vehicle IDs between 400 - 611!");
    if(color> 255 || color< 0) return SendClientMessage(playerid, 0xFFFFFF, "Car color ID's: 0-255");
    if(color2> 255 || color2< 0) return SendClientMessage(playerid, 0xFFFFFF, "Car color ID's: 0-255");
    GetPlayerPos(playerid, cPos[0], cPos[1], cPos[2]);
    GetPlayerFacingAngle(playerid, cPos[3]);
    CreateVehicle(vehicle, cPos[0], cPos[1]-3, cPos[2], cPos[3], color, color2, -1);
    return 1;
}
@SnG.Scot_MisCuDI: your command won't work properly, i guess.
Reply
#5

alright, thanks guys made it work. and the "u" was accidently added :P was just supposed to be iii lol
Reply
#6

Quote:
Originally Posted by SnG.Scot_MisCuDI
Посмотреть сообщение
pawn Код:
CMD:aveh(playerid, params[])
{
        if(!IsPlayerAdmin(playerid)) return 0; //same as that client message you made
    if(isnull(params)) return Usage(playerid, "/car [model]");

    new veh, col[2];
    new tmp[32],string[148];

    if(sscanf(params, "s[32]I(-1)I(-1)", tmp, col[0], col[1])) return SendClientMessage(playerid, COLOR_RED, "/aveh [model] [color] [color]");

    if(vehicle < 400 || vehicle > 611) return SendClientMessage(playerid,COLOR_RED, "vehcile IDs between 400 - 611!");
    if(col[0] || col[1] > 255 || col[0] || col[1]< 0) return SendClientMessage(playerid, 0xFFFFFF, "Car color ID's: 0-255");

    new Float:cPos[4];

    GetPlayerPos(playerid, cPos[0], cPos[1], cPos[2]);
    GetPlayerFacingAngle(playerid, cPos[3]);

    CreateVehicle(vehicle, cPos[0], cPos[1]-3, cPos[2], cPos[3], col[0], col[1], -1);
    return 1;
}
try that
You need to look at tutorials on zcmd/sscanf, seriously.
Reply
#7

lol i tried changing my code to his and didnt realize the strings left in there
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)