Can someone help me convert this to ZCMD? -
101 - 06.12.2012
pawn Код:
if(strcmp(cmd, "/car", true) == 0)
{
if(PlayerData[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, "You are not admin level 2.");
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /car [carid/name] [color1] [color2]");
new car = GetVehicleModelFromName(tmp);
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid, X,Y,Z);
new carid = CreateVehicle(car, X,Y+5,Z+1, 0.0, 0, 1, 60000);
CreatedCars[CreatedCar] = carid;
CreatedCar ++;
PutPlayerInVehicle( playerid, carid, 0 );
return 1;
}
I got to this:
pawn Код:
CMD:car(playerid, params[])
{
new id;
if(PlayerData[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, "You Are Not Admin Level 2.");
if(sscanf(params, "s", id)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /car [ID/NAME]");
new car = GetVehicleModelFromName(id);
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid, X,Y,Z);
new carid = CreateVehicle(car, X,Y+5,Z+1, 0.0, 0, 1, 60000);
CreatedCars[CreatedCar] = carid;
CreatedCar ++;
PutPlayerInVehicle( playerid, carid, 0 );
return 1;
}
Error I get is: error 035: argument type mismatch (argument 1)
Line: new car = GetVehicleModelFromName(id);
Re: Can someone help me convert this to ZCMD? -
LarzI - 06.12.2012
Change this
to this
pawn Код:
new id[20]; //20 cells just to be sure you can fit all the vehicles' names
I also recommend doing a check if the input is numerical so that if a player actually types in the model ID as a parameter, the command won't try to get the vehicle model from, for example, the name "435".
Re: Can someone help me convert this to ZCMD? -
Konstantinos - 06.12.2012
Let me explain me what your mistake was. You have a custom function "GetVehicleModelFromName" that it has input a string and convert the name of the vehicle to the id and it returns also that id. It is expecting to find a string, although you used id as an integer and BOOM, the error appear. The solution is what LarzI said! However, don't forget to change the parameters on the sscanf too.
pawn Код:
new
id[ 32 ]
;
if(sscanf(params, "s[32]", id)) return // continue;
Re: Can someone help me convert this to ZCMD? -
LarzI - 06.12.2012
Quote:
Originally Posted by Dwane
However, don't forget to change the parameters on the sscanf too.
|
Ah yes, thanks for correcting my mistake of not providing the cells in the sscanf argument.
Re: Can someone help me convert this to ZCMD? -
101 - 06.12.2012
Thanks guys.