How to modify this cmd -
NinjaChicken - 14.09.2012
ok i have this cmd
pawn Код:
CMD:createpvehicle(playerid, params[])
{
if (PlayerInfo[playerid][pAdmin] < 4)
{
SendClientMessageEx(playerid, COLOR_GREY, " You are not allowed to use this command.");
return 1;
}
new string[128], giveplayerid, modelid, color1, color2;
if(sscanf(params, "uddd", giveplayerid, modelid, color1, color2)) return SendClientMessageEx(playerid, COLOR_REALRED, "USAGE: /createpvehicle [playerid] [modelid] [color 1] [color 2]");
if(color1 < 0 || color1 > 126) { SendClientMessageEx(playerid, COLOR_GREY, " Color Number can't be below 0 or above 126 !"); return 1; }
if(color2 < 0 || color2 > 126) { SendClientMessageEx(playerid, COLOR_GREY, " Color Number can't be below 0 or above 126 !"); return 1; }
if(modelid < 400 || modelid > 611) { SendClientMessageEx(playerid, COLOR_GREY, " Vehicle Number can't be below 400 or above 611 !"); return 1; }
new playervehicleid = GetPlayerFreeVehicleId(giveplayerid);
if(playervehicleid == -1) return SendClientMessageEx(playerid, COLOR_GREY, "ERROR: That player can't have more cars.");
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)
{
SendClientMessageEx(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);
SendClientMessageEx(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 1;
}
i want it changed to this, /giftcar ID then i type a ID then a dialog pops up for that player allowing them to enter a vehicle id in that they want then it gets created please help asap
Re: How to modify this cmd -
Boooth - 14.09.2012
So you definitely need the dialog box for a vehicle ID?
I'm going to have to know exactly what you want it to do and what has the previous command got anything to do with what you want?
EDIT: Oh... alright I get it.
Re: How to modify this cmd -
NinjaChicken - 14.09.2012
well yea basically i just showed this cmd as an idea of how the cars are added to the player profile but is it possible to get a cmd /giftcar ID then it will show the dialog to that player they enter the car id they want and it spawns in front of them and its theirs to keep forever
Re: How to modify this cmd -
Deal-or-die - 14.09.2012
Are you using sscanf?
or can you?
Re: How to modify this cmd -
Boooth - 14.09.2012
pawn Код:
#define DIALOG_GIFTCAR (6733)
CMD:giftcar(playerid, params)
{
if(PlayerInfo[playerid][pAdmin] < 4)
{
SendClientMessageEx(playerid, COLOR_GREY, " You are not allowed to use this command.");
return 1;
}
new
giveplayerid;
if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_REALRED, "USAGE: /giftcar [playerid]");
ShowPlayerDialog(giveplayerid, DIALOG_GIFTCAR, DIALOG_STYLE_INPUT, "Gifted Car", "Insert the Model ID of the vehicle you want below", "Proceed", "Decline");
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
switch(dialogid)
{
case DIALOG_GIFTCAR:
{
if(!response) return 0;
if(strlen(inputtext) != 3 || strval(inputtext) < 411 || strval(inputtext) > 600)
return ShowPlayerDialog(playerid, DIALOG_GIFTCAR, DIALOG_STYLE_INPUT, "Gifted Car", "Insert the Model ID of the vehicle you want below", "Proceed", "Decline");
new
playervehicleid = GetPlayerFreeVehicleId(playerid);
if(playervehicleid == -1) return SendClientMessageEx(playerid, COLOR_GREY, "ERROR: That player can't have more cars.");
new
new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid,X,Y,Z);
new Float:Angle;
GetPlayerFacingAngle(playerid,Angle);
new
car1 = CreatePlayerVehicle(playerid, playervehicleid, inputtext, X, Y, Z, Angle, 0, 0, 0);
if(car1 == INVALID_PLAYER_VEHICLE_ID)
{
SendClientMessageEx(playerid, COLOR_GREY, "ERROR: Something went wrong and the car didn't get created.");
}
else
{
new string[64];
format(string, sizeof(string), " Vehicle successfully created with ID %d.", car1);
SendClientMessageEx(playerid, COLOR_GRAD1, string);
}
}
}
return 1;
}
}
I hope you know where to move it all too.
Re: How to modify this cmd -
NinjaChicken - 14.09.2012
for some reason that code just crashes my compiler
Re: How to modify this cmd -
Deal-or-die - 14.09.2012
Okay I gotta go out but it's something like this if no-ones beat me too it :P
pawn Код:
new invalidvehicle[48][22] = {
"608",// stairs
"610",//Trailer
"611",//Trailer
"607",//Trailer
"606",//Trailer
"601",//SWAT
"596",//Policecar
"597",//Policecar
"598",//Policecar
"599",//Policecar
"584",//Trailer
"570",//Train
"538",//Train
"537",//Train
"520",//Hydra
"535"//Hunter
};
command(giftcar,playerid,params[])
{
if(PlayerInfo[playerid][pAdmin] <= 1) SendClientMessage(playerid,COLOR_GREY,"You're unauthorised to use this command.");
else
{
new player;
if(sscanf(params, "u", player))
{
SendClientMessage(playerid,COLOR_GREY, "Usage: /giftcar [player]");
return 1;
}
else
{
ShowPlayerDialog(player,1,DIALOG_STYLE_INPUT,"Vehicle Selection", "Please Select a vehicle you wish to own","Continue","Cancel");
return 1;
}
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case 1:
{
if(!response) return 1;
else
{
if(IsNumeric(inputtext))
{
if(strval(inputtext) > 400 || strval(inputtext) < 611)
{
if(strval(inputtext) != invalidvehicle)
{
new string[50];
PlayerInfo[playerid][pVehicle1] = inputtext;
format(string,sizeof(string),"You have selected vehicle model: %d.",inputtext);
SendClientMessage(playerid,COLOR_WHITE,string);
}
else SendClientMessage(playerid,COLOR_WHITE,"This ID is invalid, Please input a value between 400 to 611");
}
else SendClientMessage(playerid,COLOR_WHITE,"Please input a value between 400 to 611");
}
else SendClientMessage(playerid,COLOR_WHITE,"Please input a value between 400 to 611");
}
}
}
return 1;
}
IsNumeric(const numeric[])
{
for (new i = 0, j = strlen(numeric); i < j; i++)
{
if (numeric[i] > '9' || numeric[i] < '0') return 0;
}
return 1;
}
(Sorry I took awhile went out for a coffee)