Need help with setting vehicle prices
#1

So i made a dealership parking lot and whenever I get onto the vehicle to buy it.



I just want to be able to set the price for each individual vehicle.
I don't know if this is an ingame Command or what?

Heres some lines of coding that i think may be helpful.
(I have a friend helping me through coding certain things but he's never done a dealership)


Код:
 case DIALOG_BUYCAR:
        {
            if (!response) return RemovePlayerFromVehicle(playerid);
            if(response)
			{
			    new car, str[126], ownedcar;
				car = GetVehicleModel(GetPlayerVehicleID(playerid));
		    	for(new x;x<MAX_PLAYER_VEHICLES;x++)
				{
					if(GetVehicleCost(car) == -1) { SendClientMessage(playerid, -1, "Default price has not been changed yet, you can not buy this vehicle."); RemovePlayerFromVehicle(playerid); return 1; }
					if(PlayerInfo[playerid][pVehicle][x] == 0)
  					{
  					    new rand = random(255), rand2 = random(255);
  					    if(PlayerInfo[playerid][pCash] < GetVehicleCost(car)) { SendClientMessage(playerid, -1, "You don't have enough cash."); RemovePlayerFromVehicle(playerid); return 1; }
				   		PlayerInfo[playerid][pVehicle][x] = car;
				   		PlayerInfo[playerid][pCash] -= GetVehicleCost(car);
						SetVehicleToRespawn(GetPlayerVehicleID(playerid));
				   		RemovePlayerFromVehicle(playerid);
				   		PlayerInfo[playerid][pVehicleSpawned][x] = 1;
				   		PlayerInfo[playerid][pVehiclePosX][x] = 555.87;
				   		PlayerInfo[playerid][pVehiclePosY][x] = -1265.16;
				   		PlayerInfo[playerid][pVehiclePosZ][x] = 17.24;
				   		PlayerInfo[playerid][pVehicleCol1][x] = rand;
				   		PlayerInfo[playerid][pVehicleCol1][x] = rand2;
				   		ownedcar = CreateVehicle(car, PlayerInfo[playerid][pVehiclePosX][x], PlayerInfo[playerid][pVehiclePosY][x], PlayerInfo[playerid][pVehiclePosZ][x], 0, rand, rand2, 0);
                        PlayerInfo[playerid][pVehicleSpawnedID][x] = ownedcar;
						PutPlayerInVehicle(playerid, ownedcar, 0);
				  		format(str, sizeof(str), "MoneyTrace: %s bought a car (MID: %i) for %i.", GetName(playerid), car, GetVehicleCost(car));
				   		Log("/logs/moneytrace.txt", str);
						format(str, sizeof(str), "You bought a car for %i. (%i)", GetVehicleCost(car), ownedcar);
						SendClientMessage(playerid, -1, str);
						new plate[126];
						format(plate, sizeof(plate), "LS%i", ownedcar);
						SetVehicleNumberPlate(ownedcar, plate);
						break;
   					}
				}
			}
		}
Reply
#2

The default integer for any variable is -1, so unless you set it, it'll be -1, as you know.
Make a command if there isn't one already, to set the price. Something like /setvprice [vehicleid] [price]
Reply
#3

Quote:
Originally Posted by glbracer
Посмотреть сообщение
The default integer for any variable is -1, so unless you set it, it'll be -1, as you know.
Make a command if there isn't one already, to set the price. Something like /setvprice [vehicleid] [price]
Thank you
Reply
#4

Can someone make this for me? I need a little help :/
Reply
#5

Sure.
pawn Код:
CMD:setvprice(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, COLOR_RED, "You can't use this command.");
new vid, price, string[256];
if(sscanf(params, "ii", vid, price)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /setvprice [vehicleid] [price]");
if(!IsValidVehicle(vid)) return SendClientMessage(playerid, COLOR_RED, "There isn't a vehicle with that ID.");
if(IsValidVehicle(vid) && !isnull(params))
{
VehicleInfo[vid][vPrice] = price;
format(string, sizeof(string), "You have change vehicle %d's price to $%d", vid, price);
SendClientMessage(playerid, COLOR_GREEN, string);
}
return 1;
}
Make sure you change your enum and pInfo and vInfo or cInfo whatever you use, just make sure everything's name correctly, I don't know what your enumerators look like. Shoot me a forum PM if you need any help.
Reply
#6

I love you.
Reply
#7

Hey I am doing the same thing and I am kind of new to all of this and when I plugin the code and compile I get this:

C:\Users\ethan\Desktop\SAMP Server\gamemodes\RP.pwn(174 : error 017: undefined symbol "IsValidVehicle"
C:\Users\ethan\Desktop\SAMP Server\gamemodes\RP.pwn(1749) : error 017: undefined symbol "IsValidVehicle"
C:\Users\ethan\Desktop\SAMP Server\gamemodes\RP.pwn(1751) : error 017: undefined symbol "VehicleInfo"
C:\Users\ethan\Desktop\SAMP Server\gamemodes\RP.pwn(1751) : warning 215: expression has no effect
C:\Users\ethan\Desktop\SAMP Server\gamemodes\RP.pwn(1751) : error 001: expected token: ";", but found "]"
C:\Users\ethan\Desktop\SAMP Server\gamemodes\RP.pwn(1751) : error 029: invalid expression, assumed zero
C:\Users\ethan\Desktop\SAMP Server\gamemodes\RP.pwn(1751) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


6 Errors.


Do I need to add a #define for isValidVehicle? If so how would I word it.
Reply
#8

Quote:
Originally Posted by ethman326
Посмотреть сообщение
Hey I am doing the same thing and I am kind of new to all of this and when I plugin the code and compile I get this:

C:\Users\ethan\Desktop\SAMP Server\gamemodes\RP.pwn(174 : error 017: undefined symbol "IsValidVehicle"
C:\Users\ethan\Desktop\SAMP Server\gamemodes\RP.pwn(1749) : error 017: undefined symbol "IsValidVehicle"
C:\Users\ethan\Desktop\SAMP Server\gamemodes\RP.pwn(1751) : error 017: undefined symbol "VehicleInfo"
C:\Users\ethan\Desktop\SAMP Server\gamemodes\RP.pwn(1751) : warning 215: expression has no effect
C:\Users\ethan\Desktop\SAMP Server\gamemodes\RP.pwn(1751) : error 001: expected token: ";", but found "]"
C:\Users\ethan\Desktop\SAMP Server\gamemodes\RP.pwn(1751) : error 029: invalid expression, assumed zero
C:\Users\ethan\Desktop\SAMP Server\gamemodes\RP.pwn(1751) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


6 Errors.


Do I need to add a #define for isValidVehicle? If so how would I word it.
There's a SAMP bug where IsValidVehicle isn't defined natively, at the top of your script type 'native IsValidVehicle(vehicleid);'
Reply
#9

Quote:
Originally Posted by glbracer
Посмотреть сообщение
The default integer for any variable is -1, so unless you set it, it'll be -1, as you know.
Make a command if there isn't one already, to set the price. Something like /setvprice [vehicleid] [price]
Quote:
Originally Posted by glbracer
Посмотреть сообщение
There's a SAMP bug where IsValidVehicle isn't defined natively, at the top of your script type 'native IsValidVehicle(vehicleid);'
Do you think you could hop on teamviewer and help me?
Reply
#10

The 'native IsValidVehicle(vehicleid);' only fixed 2errors.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)