30.09.2011, 15:21
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).
And this in OnGameModeInit:
OK,now I created bassically the functions for the vehicle:
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:
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:
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
it says it's an invalid expression.Therefor,it's like I defined MAX_CARS for nothing.PLEASE HELP.
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;
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);
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]);
}
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);
}
}
Код:
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
LAST THING I WANNA say that if in OnPlayerStateChange I use
Код:
for(new i = 0;i<MAX_CARS;i++)