Help with /sellcar !
#1

Hello,
so can someone help me how to /sellcar to be on particular place and if player is not at that place will return him "Error : You are not at car selling lot!:.
and when he does /sellcar it will spawn car at random place at car lot ? please help me
code:
pawn Код:
if(strcmp(cmd, "/sellcar",true)==0)
    {
    new tmp[256];
    tmp = strtok(cmdtext, idx);
    if(strlen(tmp) > 16)
   
    new tmpprice = strval(tmp);
    if(!strlen(tmp))
    {
        SendClientUsage(playerid, cmd, "[amount]");
        return 1;
    }
    if(tmpprice < 1)
    {
        SendClientWarning(playerid, "Invalid price");
        return 1;
    }
    if(tmpprice > 50000000)
    {
        SendClientWarning(playerid, "Max Amount 50mil");
        return 1;
    }
    new
        carfile[ 60 ],
        stringa[ 256 ],
        r = GetPlayerVehicleID(playerid);

        format(carfile, sizeof(carfile),"cars/Car%d.txt", Vehicles[r][cID]);
        new asker[MAX_STRING];
        format(asker, MAX_STRING, "%s", PlayerName(playerid));
        new ownh[MAX_STRING];
        ownh = dini_Get(carfile,"owner");
       /** here is what i done but its not working **/ if(!IsPlayerInRangeOfPoint(playerid, 10.0, 7321,1448.7345,14.9060,332)) return SendClientError (playerid, " You are not at car selling lot!");
        if(!IsPlayerDriver(playerid)) return SendClientError(playerid," You must be the driver of a vehicle." );
        if(Vehicles[r][cartype] != 69) return SendClientError(playerid,"Error occured, this vehicle its not ownable!" );
        if(Vehicles[r][cOwned] == 1 && strcmp(asker,ownh,false)==0)
        {
        /** and here is the rangepoint**/   IsPlayerInRangeOfPoint(playerid, 10.0, 7321,1448.7345,14.9060,332);
            dini_IntSet(carfile,"carvalue",tmpprice);
            Vehicles[r][carvalue] = tmpprice;
            dini_IntSet(carfile,"forsale",1);
            Vehicles[r][forsale] = 1;

            format(stringa,sizeof(stringa),"[Vehicle] You have put this vehicle on sale. Price: $%i",tmpprice);
            SendClientInfo(playerid, stringa);
            return 1;
        }
        else SendClientError(playerid,"You dont own this car !");
    }
Reply
#2

Replace Range, X, Y and Z.

pawn Код:
if(!IsPlayerInRangeOfPoint(playerid, RANGE, X, Y ,Z))
{
    SendClientMessage(playerid, -1,"Error: You are not at the showroom!");
}
Remove the 2nd IsPlayerInRangeOfPoint from your command. The first one should in theory work, but you can try placing it above the money thing using my code.
Reply
#3

First make en enum like that for the random car spawn.
pawn Код:
enum carspawn
{
    Float: cX,
    Float: cY,
    Float: cZ,
        Float: cA
}
new Cars[][carspawn] =
{
    {x,y,z,a},
    {x,y,z,a}
};
Then before the strlen check if the player is at the car lot.
If not return some message.

To set the car spawn, set it after this part of the command:
pawn Код:
dini_IntSet(carfile,"carvalue",tmpprice);
            Vehicles[r][carvalue] = tmpprice;
            dini_IntSet(carfile,"forsale",1);
            Vehicles[r][forsale] = 1;
And when I say set the car spawn I mean to set it in the Car%d.txt using the random spawn spots.
Reply
#4

Can you implement those things in the code pls ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)