[Help] Creating cars by their ID's
#1

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! ".
Reply
#2

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.");
    }
Reply
#3

LOL!
Thanks mate!
I found a couple of bugs more in that command but everything is fixed now, thanks to you!
Reply
#4

here ya go
pawn Код:
new vecid = strval(tmp);
        if(vecid >= 400 && vecid <= 611)
Reply
#5

Ermm... I already fixed that.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)