[HELP]Vehicle Ownership!(need FAST)
#1

OK,so I don't know if you remember,or it doesn't matter anyway.I started scripting a new Vehicle Ownership System.And there are a few bugs.Anyway first I will explain how my vehicle system will be working or is supossed to work.PAY ATTENTION!!!
I added some vehicles in front of a dealership-building in SF(the city I use in my GM).

pawn Код:
new Bullet;
new Turismo;
new Cheetah;
And this in OnGameModeInit:

pawn Код:
Bullet = CreateVehicle(541,-1975.4666,296.0619,34.8772,45,0,0,0);
Turismo = CreateVehicle(441,-1974.3268,299.4523,34.9750,45,0,0,0);
Cheetah = CreateVehicle(415,-1976.6947,293.2100,34.9724,45,0,0,0);
OK,now I created bassically the functions for the vehicle:

pawn Код:
#define MAX_CARS

enum vInfo
{
  vOwner[MAX_PLAYER_NAME],
  vPrice,
  bool:vOwned,
  vModel,
  vFloatX,
  vFloatY,
  vFloatZ,
  vSell,
}
new VehicleInfo[MAX_CARS][vInfo];

stock LoadVehicles(vehicleid)
{
  new playerid;
  new vstring[10];
  new pName[MAX_PLAYER_NAME];
  GetPlayerName(playerid,pName,sizeof(pName));
  format(vstring,sizeof(vstring),"VehicleOwnership/%s"pName);
  if(!dini_Exists(vstring)) return 0;
  VehicleInfo[vehicleid][vPrice] = dini_Int(vstring,"VehPrice");
  VehicleInfo[vehicleid][vModel] = dini_Int(vstring,"VehModel");
  VehicleInfo[vehicleid][vOwned] = dini_Bool(vstring,"VehOwned") ? true : false;
  VehicleInfo[vehicleid][vSell] = dini_Bool(vstring,"VehForSell") ? true : false;
  VehicleInfo[vehicleid][vFloatY] = dini_Float(vstring,"VehFloatY");
  VehicleInfo[vehicleid][vFloatZ] = dini_Float(vstring,"VehFloatZ");
  VehicleInfo[vehicleid][vFloatX] = dini_Float(vstring,"VehFloatX");
  strmid(VehicleInfo[vehicleid][vOwner], dini_Get(vstring, "VehOwner"), 0, false, strlen(dini_Get("VehOwner")));
}

stock SaveVehicles(vehicleid)
{
  new playerid;
  new vstring[10];
  new pName[MAX_PLAYER_NAME];
  GetPlayerName(playerid,pName,sizeof(pName));
  format(vstring,sizeof(vstring),"VehicleOwnership/%s"pName); // error line 213
  if(!dini_Exists(vstring)) return 0;
  dini_Get(vstring,"Owner",VehicleInfo[vehicleid][vOwner]);
  dini_BoolSet(vstring,"VehOwned",VehicleInfo[vehicleid][vOwned]);
  dini_BoolSet(vstring,"VehForSell",VehicleInfo[vehicleid][vSell]);
  dini_IntSet(vstring,"VehPrice",VehicleInfo[vehicleid][vPrice]);
  dini_IntSet(vstring,"VehModel",VehicleInfo[vehicleid][vModel]);
  dini_FloatSet(vstring,"VehFloatX",VehicleInfo[vehicleid][vFloatX]);
  dini_FloatSet(vstring,"VehFloatY",VehicleInfo[vehicleid][vFloatY]);
  dini_FloatSet(vstring,"VehFloatZ",VehicleInfo[vehicleid][vFloatZ]);
}
OK,actually NOW I will explain how I want the system to work.If a player enters a car of ONLY THE ONES ADDED IN FRONT OF THE CAR-DEALERSHIP,he will see a dialog wich tells him the car info.If he agrees to buy the car,THEN HE WON'T BE BUYING THE CAR HE ENTERED,BUT ANOTHER VEHICLE(same ID with the one that the player agreed to buy)WILL BE CREATED AT A POSITION defined by me,AND THE VEHICLE CREATED(NOT THE ONE IN FRONT OF THE DEALERSHIP THAT HE ENTERED) will belong to him.I basically have the idea in my head,and I don't need very much help,but the errors are the following.I defined the created-cars(the ones in front of Dealership) price.And here's the OnPlayerStateChange:

pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
      {
         if(vehicleid == Cheetah)
         {
            new pName[MAX_PLAYER_NAME];
            GetPlayerName(playerid,pName,sizeof(pName));
            VehicleInfo[vehicleid][vOwned] = true;
            strmid(VehicleInfo[vehicleid][vOwner], pName, 0, false, strlen(pName));
            GivePlayerMoney(playerid, -VehicleInfo[Cheetah][vPrice]);
            SendClientMessage(playerid, COLOR_GREEN, "Car bought!");
            SaveVehicles(vehicleid);
         }
      }
AND NOW,you're wondering why now the vehicle that was supossed to be the untouched one IS ACTUALLY THE BHOUGHT 1.Because this is just a test,and making the created-vehicle owned 1 is easy.Anyway the errors ARE:

Код:
D:\Jocuri\GTA\GTA San Andreas\SAMP\samp03csvr_R5_win32\gamemodes\sfcnr.pwn(213) : error 001: expected token: "-string end-", but found "-identifier-"
D:\Jocuri\GTA\GTA San Andreas\SAMP\samp03csvr_R5_win32\gamemodes\sfcnr.pwn(213) : warning 215: expression has no effect
D:\Jocuri\GTA\GTA San Andreas\SAMP\samp03csvr_R5_win32\gamemodes\sfcnr.pwn(213) : error 001: expected token: ";", but found ")"
D:\Jocuri\GTA\GTA San Andreas\SAMP\samp03csvr_R5_win32\gamemodes\sfcnr.pwn(213) : error 029: invalid expression, assumed zero
D:\Jocuri\GTA\GTA San Andreas\SAMP\samp03csvr_R5_win32\gamemodes\sfcnr.pwn(213) : fatal error 107: too many error messages on one line
As you can notice is the saving-system.What I want is to create a *.txt file with the player's name in a folder called Vehicle Ownership.And in the txt file is supossed to be the infos you can see in the function :P.The floats aren't supossed to be the CAR IN FRONT OF DEALERSHIP POSITION BUT THEY'RE SUPOSSED TO BE USED with a command called /park wich will be implemented later,as there's no point to create it now.

LAST THING I WANNA say that if in OnPlayerStateChange I use
Код:
for(new i = 0;i<MAX_CARS;i++)
it says it's an invalid expression.Therefor,it's like I defined MAX_CARS for nothing.PLEASE HELP.
Reply
#2

any1 pls?
Reply
#3

pawn Код:
format(vstring,sizeof(vstring),"VehicleOwnership/%s"pName);
To


pawn Код:
format(vstring,sizeof(vstring),"VehicleOwnership/%s",pName);
Reply
#4

Excuse me,but I don't really know how to say thanks to you,CAUSE YOU HAVE AN AMAZING eye,or I hope it's not just me and I should wear glasses,thanks very much,i'll be back with the topic if something goes wrong but so far it compiles good :P
Reply
#5

ok back on my topic after I answered more than 5 :P(I hope I'll get help now also xD)

how to use the for(new i=0;i<MAX_CARS;i++)?
Reply
#6

pawn Код:
for( new i = 0; i < MAX_VEHICLES; i++)
{
    // Do your code
}


pawn Код:
#define MAX_CARS (number)
for( new i = 0; i < MAX_CARS; i++)
{
    // Do your code
}
Reply
#7

thx jaffet you should have read my topic description carefully you can notice when i say

LAST THING I WANNA say that if in OnPlayerStateChange I use
Code:
for(new i = 0;i<MAX_CARS;i++)
it says it's an invalid expression.Therefor,it's like I defined MAX_CARS for nothing.PLEASE HELP.

so?hellp?
Reply
#8

Well, I told you, you should NOT define MAX_CARS as:
pawn Код:
#define MAX_CARS
. It should be
pawn Код:
#define MAX_CARS 500
Example
Reply
#9

OMG,all excuses to you,please forgive me,I COULD HAVE SWEARED it was #define MAX_CARS 500,lol how could I forgot the 500 :O
Reply
#10

hmm if I try to use it as

pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
{
for(new i =0;i<MAX_CARS;i++)
{
if(vehicleid == Bullet || vehicleid == Cheetah ||  vehicleid == Turismo)
{
     new string[120];
     format(string,sizeof(string),"Price:%d",VehicleInfo[i][vPrice]);
     ShowDialogForPlayer(playerid,5,DIALOG_STYLE_MSGBOX,"CarDealership",string,"Accept","Quit");
}
}
}
And,it works only half perfectly,because the dialog doesn't show for every car as you may think,it shows only for the correct cars,but despite the fact I defined the prices for the cars,it show "0" for each.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)