Question about defines...
#1

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(1151958.37831343.157215.3746269.1425000000);
    
Chaos AddStaticVehicle(4112505.4805, -1694.454813.5583359.351000);
    
Chaos AddStaticVehicle(4112530.1431, -1667.077815.168475.842000);
    
Chaos AddStaticVehicle(5222507.5515, -1652.731013.6477145.234400);
    
Chaos AddStaticVehicle(5222504.8083, -1651.408613.6138146.487700);
    
Chaos AddStaticVehicle(5222491.7473, -1686.499913.5120351.554600);
    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.
Reply
#2

PHP код:

//Replace where you defined Chaos with
new Chaos[5];
public 
OnGameModeInit()
{
    
SetGameModeText("DM/Stunt/Freeroam/DM");
    
AddPlayerClass(1151958.37831343.157215.3746269.1425000000);
    
Chaos[0] = AddStaticVehicle(4112505.4805, -1694.454813.5583359.351000);
    
Chaos[1] = AddStaticVehicle(4112530.1431, -1667.077815.168475.842000);
    
Chaos[2] = AddStaticVehicle(5222507.5515, -1652.731013.6477145.234400);
    
Chaos[3] = AddStaticVehicle(5222504.8083, -1651.408613.6138146.487700);
    
Chaos[4] = AddStaticVehicle(5222491.7473, -1686.499913.5120351.554600);
    return 
1;

Reply
#3

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
Reply
#4

Quote:
Originally Posted by McCarthy
Посмотреть сообщение
PHP код:

//Replace where you defined Chaos with
new Chaos[5];
public 
OnGameModeInit()
{
    
SetGameModeText("DM/Stunt/Freeroam/DM");
    
AddPlayerClass(1151958.37831343.157215.3746269.1425000000);
    
Chaos[0] = AddStaticVehicle(4112505.4805, -1694.454813.5583359.351000);
    
Chaos[1] = AddStaticVehicle(4112530.1431, -1667.077815.168475.842000);
    
Chaos[2] = AddStaticVehicle(5222507.5515, -1652.731013.6477145.234400);
    
Chaos[3] = AddStaticVehicle(5222504.8083, -1651.408613.6138146.487700);
    
Chaos[4] = AddStaticVehicle(5222491.7473, -1686.499913.5120351.554600);
    return 
1;

Oh lol,I didn't scripted for ages ..
Thanks! ++REP
Reply
#5

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!
Reply
#6

use
new Chaos[amount of cars];

S
pawn Код:
new Chaos[5]
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...
Reply
#7

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.
Reply
#8

Where did you created,
pawn Код:
new Chaos[5];
?
Reply
#9

after the includes.
Reply
#10

You have an array for it,or you made the variable yet?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)