[Help] Creating cars by their ID's - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Help] Creating cars by their ID's (
/showthread.php?tid=196316)
[Help] Creating cars by their ID's -
Alex_Valde - 05.12.2010
I've trying to create like command what will give you the car (by his ID) you want.
It works pretty nicely, but I've got one small problem what I can't think of way to get rid.
So this is the code:
The dialog when you call the " /veh " command:
pawn Код:
ShowPlayerDialog(playerid, ADMIN_CARSID_DIALOG,DIALOG_STYLE_INPUT,"Vehicle ID","Please enter ID of your vehicle.","Spawn","Cancel");
pawn Код:
if(dialogid == ADMIN_CARSID_DIALOG)
{
if(!response) return SendClientMessage(playerid, COLOR_LIGHTRED, " You Canceled!");
new carid = strval(inputtext);
if(!IsNumeric(inputtext)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Please use numbers as a ID of your car. [HINT]: Please use ID 400-605.");
if(inputtext[0] > 400 || inputtext[0] < 605)// Here is the problem, I think. :S
{
new Float:X, Float:Y, Float:Z, Float:A;
GetPlayerFacingAngle(playerid, A);
GetPlayerPos(playerid,X, Y, Z);
AdminCar = AddStaticVehicle(carid, X+2, Y+3, Z, A, 0, 0);
SendClientMessage(playerid, COLOR_GREEN, " You got your car!");
}
else return SendClientMessage(playerid, COLOR_LIGHTRED, "Sorry, but we can't find a car with ID you wanted. [HINT]: Please use ID 400-605.");
}
And the problem is when i put like 20 in the dialog box, and we all know that there is no car with ID 20.
But I still get the message "
You got your car! ".
Re: [Help] Creating cars by their ID's -
Zimon95 - 05.12.2010
Use &&
pawn Код:
if(dialogid == ADMIN_CARSID_DIALOG)
{
if(!response) return SendClientMessage(playerid, COLOR_LIGHTRED, " You Canceled!");
new carid = strval(inputtext);
if(!IsNumeric(inputtext)) return SendClientMessage(playerid, COLOR_LIGHTRED, "Please use numbers as a ID of your car. [HINT]: Please use ID 400-605.");
if(inputtext[0] > 400 && inputtext[0] < 605)// Here is the problem, I think. :S
{
new Float:X, Float:Y, Float:Z, Float:A;
GetPlayerFacingAngle(playerid, A);
GetPlayerPos(playerid,X, Y, Z);
AdminCar = AddStaticVehicle(carid, X+2, Y+3, Z, A, 0, 0);
SendClientMessage(playerid, COLOR_GREEN, " You got your car!");
}
else return SendClientMessage(playerid, COLOR_LIGHTRED, "Sorry, but we can't find a car with ID you wanted. [HINT]: Please use ID 400-605.");
}
Re: [Help] Creating cars by their ID's -
Alex_Valde - 05.12.2010
LOL!
Thanks mate!
I found a couple of bugs more in that command but everything is fixed now, thanks to you!
Re: [Help] Creating cars by their ID's -
fangoth1 - 05.12.2010
here ya go
pawn Код:
new vecid = strval(tmp);
if(vecid >= 400 && vecid <= 611)
Re: [Help] Creating cars by their ID's -
Alex_Valde - 05.12.2010
Ermm... I already fixed that.