
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;
}
}
}
}
|
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] |
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;
}
: error 017: undefined symbol "IsValidVehicle"|
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. |
|
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] |
|
There's a SAMP bug where IsValidVehicle isn't defined natively, at the top of your script type 'native IsValidVehicle(vehicleid);'
|