[HELP] Derby code not executing..
#1

pawn Код:
forward EventStart();
public EventStart()
{
    time++;
    if (time == 20 && active == 0)
    {
        SendClientMessageToAll(-1, ""YELLOW"[EVENT] {5DF0BF}Derby event has started! Type "YELLOW"/derby {5DF0BF}to sign up for the event!");
        active = 1;
        time = 0;
        gDerbyTimer = SetTimer("SignUpAndDerbyStart", 1000, true);
    }
    return 1;
}

forward SignUpAndDerbyStart();
public SignUpAndDerbyStart()
{
    new str[128];
    t2++;
    if (t2 == 5 && active == 1)
    {
    /*  if (totalplayers < 0)
        {
            for (new i = 0; i < MAX_PLAYERS; i++)
            {
                if (IsPlayerConnected(i))
                {
                    if (PlayerInfo[i][DerbySignUp] == 1)
                    {
                        PlayerInfo[i][DerbySignUp] = 0;
                    }
                }
            }
            SendClientMessageToAll(-1, ""YELLOW"[EVENT] {5DF0BF}Derby event has been cancelled due to lack of participants!");
        }*/

        format(str, sizeof(str), ""YELLOW"[EVENT] {5DF0BF}Derby signups are now closed! Derby event is loading.. "REDORANGE"(Total participants: %d)", totalplayers);
        SendClientMessageToAll(-1, str);
        KillTimer(gDerbyTimer); // Nothing happens after this...
        InitiatePlayers();
    }
    return 1;
}

forward InitiatePlayers();
public InitiatePlayers()
{
        for (new i = 0; i < MAX_PLAYERS; i++)
        {
            if (IsPlayerConnected(i))
            {
                if (PlayerInfo[i][DerbySignUp] == 1)
                {
                    PlayerInfo[i][DerbySignUp] = 0;
                    new Float:RandomSpawns[][] =
                    {
                        {3231.9502,732.2703,4.1086,269.8116},
                        {3356.9399,687.2062,4.1097,90.7039},
                        {3315.5073,761.3829,17.9094,183.8474},
                        {3273.1577,697.4916,4.1110,4.3769},
                        {3356.6091,784.9301,3.9539,91.3945},
                        {3289.0208,745.3491,3.9531,1.4095},
                        {3286.6167,823.3590,3.9528,181.5422}
                    };
                    PutPlayerInVehicle(i, 424, 0);
                    new Random = random(sizeof(RandomSpawns));
                    SetPlayerVehiclePos(i, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2], RandomSpawns[Random][3]);
                }
            }
        }
        return 1;
}
InitiatePlayers(); function is not loading...
Reply
#2

Anyone?
Reply
#3

Quote:
Originally Posted by SyntaxQ
Посмотреть сообщение
Anyone?
Do you have a timer somewhere for each of those forwards? If so, please show script.

EDIT: Yes, there are timers which isn't the problem, so I can't help you further, sorry.
Reply
#4

How do you know it's not executing? You have no messages on InitiatePlayers and where did you get SetPlayerVehiclePos from?
Reply
#5

I have made a stock for SetPlayerVehiclePos, it includes an extra parameter which is facing angle. (Just to make things easy)

I don't receive any car after the message: [EVENT] Derby signups are now closed! Derby is loading..
Reply
#6

You should create the vehicle first
pawn Код:
new Random = random(sizeof(RandomSpawns));
new vid = CreateVehicle(424, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2], RandomSpawns[Random][3], -1, -1, -1);
PutPlayerInVehicle(i, vid, 0);
But you need to delete these vehicles afterwards / if they are destroyed

Also you should be aware that two players could get the same position due to random...
To prevent that I suggest to assign the position just starting from 0 till x
Reply
#7

Quote:
Originally Posted by SyntaxQ
Посмотреть сообщение
I have made a stock for SetPlayerVehiclePos, it includes an extra parameter which is facing angle. (Just to make things easy)

I don't receive any car after the message: [EVENT] Derby signups are now closed! Derby is loading..
Why do you use 424 as the ID when using PutPlayerInVehicle?
Reply
#8

Thanks a lot!

Quote:
Originally Posted by AlonzoTorres
Посмотреть сообщение
Why do you use 424 as the ID when using PutPlayerInVehicle?
PutPlayerInVehicle(playerid, vehicleid, seatid); 424 is the vehicle ID.

I have one question..
I have created random spawns for the derby players to spawn, can two players spawn at one place? (This will be a big problem) if yes, can you tell me the way to avoid this?
Reply
#9

Quote:
Originally Posted by SyntaxQ
Посмотреть сообщение
Thanks a lot!



PutPlayerInVehicle(playerid, vehicleid, seatid); 424 is the vehicle ID.

I have one question..
I have created random spawns for the derby players to spawn, can two players spawn at one place? (This will be a big problem) if yes, can you tell me the way to avoid this?
So you have 424 vehicles on your server? How can you be sure that 424 is the current vehicle created? I think you think it's vehicle MODEL but really it's model ID.

You'd have to create another variable of the type boolean to check if that specific row has been used,
PSEUDO version below:
pawn Код:
if(RandomSpawn[idx][5] == true){
    // This has been used so add one to idx and redo...
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)