Question about defines... -
jotan. - 15.10.2012
Hello.
I have some bugs in my script.
Problem is,that,I have made some PrivateCars in Los Santos Grove Street.
I made that car system based on strcmp checking player name..
But one define just 1 car,Is there any way to add more cars to 1 define
PHP код:
public OnGameModeInit()
{
SetGameModeText("DM/Stunt/Freeroam/DM");
AddPlayerClass(115, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
Chaos = AddStaticVehicle(411, 2505.4805, -1694.4548, 13.5583, 359.3510, 0, 0);
Chaos = AddStaticVehicle(411, 2530.1431, -1667.0778, 15.1684, 75.8420, 0, 0);
Chaos = AddStaticVehicle(522, 2507.5515, -1652.7310, 13.6477, 145.2344, 0, 0);
Chaos = AddStaticVehicle(522, 2504.8083, -1651.4086, 13.6138, 146.4877, 0, 0);
Chaos = AddStaticVehicle(522, 2491.7473, -1686.4999, 13.5120, 351.5546, 0, 0);
return 1;
}
This is the real problem.
It just loads one car,and I need to load all cars with "Chaos = " and prevent players to get into them.
Re: Question about defines... -
McCarthy - 15.10.2012
PHP код:
//Replace where you defined Chaos with
new Chaos[5];
public OnGameModeInit()
{
SetGameModeText("DM/Stunt/Freeroam/DM");
AddPlayerClass(115, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
Chaos[0] = AddStaticVehicle(411, 2505.4805, -1694.4548, 13.5583, 359.3510, 0, 0);
Chaos[1] = AddStaticVehicle(411, 2530.1431, -1667.0778, 15.1684, 75.8420, 0, 0);
Chaos[2] = AddStaticVehicle(522, 2507.5515, -1652.7310, 13.6477, 145.2344, 0, 0);
Chaos[3] = AddStaticVehicle(522, 2504.8083, -1651.4086, 13.6138, 146.4877, 0, 0);
Chaos[4] = AddStaticVehicle(522, 2491.7473, -1686.4999, 13.5120, 351.5546, 0, 0);
return 1;
}
Re: Question about defines... -
AIped - 15.10.2012
All cars have the same variable now. to fix it you could do
Chaos = addstaticvehicle..
Chaos1 = addstaticvehicle..
Chaos2 =....
and so on.. it should work
[Edit] what the guy above me says XD
Re: Question about defines... -
jotan. - 15.10.2012
Quote:
Originally Posted by McCarthy
PHP код:
//Replace where you defined Chaos with
new Chaos[5];
public OnGameModeInit()
{
SetGameModeText("DM/Stunt/Freeroam/DM");
AddPlayerClass(115, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
Chaos[0] = AddStaticVehicle(411, 2505.4805, -1694.4548, 13.5583, 359.3510, 0, 0);
Chaos[1] = AddStaticVehicle(411, 2530.1431, -1667.0778, 15.1684, 75.8420, 0, 0);
Chaos[2] = AddStaticVehicle(522, 2507.5515, -1652.7310, 13.6477, 145.2344, 0, 0);
Chaos[3] = AddStaticVehicle(522, 2504.8083, -1651.4086, 13.6138, 146.4877, 0, 0);
Chaos[4] = AddStaticVehicle(522, 2491.7473, -1686.4999, 13.5120, 351.5546, 0, 0);
return 1;
}
|
Oh lol,I didn't scripted for ages ..
Thanks! ++REP
Re: Question about defines... -
newbienoob - 15.10.2012
Don't use "define", use "new". Example:
new chaos;
chaos = Add......
If you wanna use multiple same variables(like in your script), use this;
new chaos[5];
chaos[0] = Add.....
chaos[2] = Add.....
.....
EDIT: TOO LATE!
Re: Question about defines... -
Roel - 15.10.2012
use
new Chaos[amount of cars];
S
pawn Код:
Chaos[0] = AddStaticVehicle(411, 2505.4805, -1694.4548, 13.5583, 359.3510, 0, 0);
Chaos[1] = AddStaticVehicle(411, 2530.1431, -1667.0778, 15.1684, 75.8420, 0, 0);
Chaos[2] = AddStaticVehicle(522, 2507.5515, -1652.7310, 13.6477, 145.2344, 0, 0);
Chaos[3] = AddStaticVehicle(522, 2504.8083, -1651.4086, 13.6138, 146.4877, 0, 0);
Chaos[4] = AddStaticVehicle(522, 2491.7473, -1686.4999, 13.5120, 351.5546, 0, 0);
THen you use loop to check if the player is in any of this cars like
pawn Код:
for (new x=0; x<5; x++)
{
if(GetPlayerVehicleID(playerid) == Chaos[x])
{
// he is in a chaos car.
}
}
[EDIT] a bit to late lol...
Re: Question about defines... -
jotan. - 15.10.2012
Still not late!
Error 033.
error 033: array must be indexed (variable "Chaos")
[Line]
if(newstate == PLAYER_STATE_DRIVER && GetPlayerVehicleID(playerid) == Chaos)
I used basic strcmp to get player name,and if it's different,then it kicks the player out of car.
Re: Question about defines... -
Roel - 15.10.2012
Where did you created,
?
Re: Question about defines... -
jotan. - 15.10.2012
after the includes.
Re: Question about defines... -
HyDrAtIc - 15.10.2012
You have an array for it,or you made the variable yet?