Sellable Cars
#1

I made a script which you can sell cars, the problem is that I want any random car you enter will either say you can sell this vehicle or not. If I go into a random sellable vehicle, it will say "you can sell this car for [$amount$]". But if I were to exit it and re-enter it again, it will say it's not sellable. I made a variable called insellablecar[MAX_PLAYERS] and set the value to 1 if they enter the random sellable vehicle. Here is the code:

pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
    {
        new rand = random(15);
        if(rand >= 0 && rand <= 6)
        {
            new string[128];
            new Value = GetVehicleValue(playerid);

            SellableVehicle[GetPlayerVehicleID(playerid)] = 1;
            insellablecar[playerid] = 1;

            format(string,sizeof(string),"You Can Sell This Vehicle At The Crane For $%d.",Value);
            SendClientMessage(playerid,COLOR_LIGHTBLUE,string);

            format(string,sizeof(string),"~w~SELL THIS VEHICLE AT ~N~THE CRANE FOR $%d",Value);
            GameTextForPlayer(playerid, string, 4000,3);
        }
        else if(rand >= 7 && rand <= 15)
        {
            insellablecar[playerid] = 0;
            if(insellablecar[playerid] == 0)
            {
                return SendClientMessage(playerid,red,"Welcome Back To Your Vehicle.");
            }
        }
    }
I know this won't and didn't work properly, but does anyone know how to fix it? Sorry if it is confusing lol :/
Reply
#2

Can you explain better?

How is it working now and how is it supposed to work?
Reply
#3

Right now, I made a random function:

pawn Код:
new rand = random(15);
So if the random numbers range from 0 to 6, the player that enters the vehicle and gets those numbers can sell the vehicle for a price. Else, if the numbers are 7 to 15, it will return 0 (not sellable).

But the problem is if they enter the sellable vehicle, it will say you can sell it but if they exit then enter it again, it will say its not sellable, and so on if you keep exiting/entering, because the random function I made interferes with it.
Reply
#4

pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
    {
        new rand = random(15);
        if(rand >= 0 && rand <= 6)
        {
            new string[128];
            new Value = GetVehicleValue(playerid);

            SellableVehicle[GetPlayerVehicleID(playerid)] = 1;
            insellablecar[playerid] = GetPlayerVehicleID(playerid);

            format(string,sizeof(string),"You Can Sell This Vehicle At The Crane For $%d.",Value);
            SendClientMessage(playerid,COLOR_LIGHTBLUE,string);

            format(string,sizeof(string),"~w~SELL THIS VEHICLE AT ~N~THE CRANE FOR $%d",Value);
            GameTextForPlayer(playerid, string, 4000,3);
        }
        else if(rand >= 7 && rand <= 15)
        {
            if(GetPlayerVehicleID(playerid) == insellablecar[playerid])
            {
                return SendClientMessage(playerid,red,"Welcome Back To Your Vehicle.");
            }
        }
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)