Help with Race! [PLEASE]
#1

Hello all! I really need your help! I created Drag Race with timer, but when time expires (15 seconds), nothing happens (it should put new chekpoint and start the race)!

Here it is:

Код:
#include <a_samp>
#define red 0xFF0000FF
#define yellow 0xFFFF00AA
#define green 0x33FF33AA

new Stats[MAX_PLAYERS];
new Started[MAX_PLAYERS];
new Joined[MAX_PLAYERS];
forward RaceStart(playerid);

main()
{
}

public OnGameModeInit()
{
    return 1;
}

public OnGameModeExit()
{
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    return 1;
}

public OnPlayerConnect(playerid)
{
	Started[playerid] = 0;
	Joined[playerid] = 0;
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    return 1;
}

public OnPlayerSpawn(playerid)
{
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/drag1", cmdtext, true, 10) == 0)
	{
	    SetPlayerPos(playerid,-772.7875,2739.6406,45.2056);
	    SetPlayerFacingAngle(playerid,180.2663);
	    SetCameraBehindPlayer(playerid);
	    SetPlayerRaceCheckpoint(playerid, 0,-779.6516,2729.7351,44.9043,-1037.9878,2709.0464,45.4293,5.0);
    	Stats[playerid] = 1;
		return 1;
	}
	if (strcmp("/startd1", cmdtext, true, 10) == 0)
	{
	if(Started[playerid] == 1)
	{
	    GameTextForPlayer(playerid,"~r~RACE ALREADY STARTED!",3000,3);
	    return 1;
	}
	    SendClientMessageToAll(green, "[RACE]: Drag Race 1 starting in 15 seconds! Type /drag1 to join!");
	    Started[playerid] = 1;
	    SetTimer("RaceStart",15000,false);
		return 1;
	}
	return 0;
}

public RaceStart(playerid)
{
	if(IsPlayerInRaceCheckpoint(playerid))
	{
		DisablePlayerRaceCheckpoint(playerid);
		PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
		SetPlayerRaceCheckpoint(playerid, 0,-1037.9878,2709.0464,45.4293,-1357.7117,2621.8223,51.8769,10);
		Stats[playerid] = 2;
		GameTextForPlayer(playerid,"~g~!!! GO GO GO !!!",3000,3);
	}
}

public OnPlayerPickUpPickup(playerid,pickupid)
{
    return 1;
}


public OnPlayerEnterCheckpoint(playerid)
{
    return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
    switch(Stats[playerid])
    {
         case 1:
         {
				GameTextForPlayer(playerid,"~g~JOINED RACE! ~r~WAIT HERE!~n~~w~TYPE ~g~/STARTD1 ~w~TO START THIS RACE!",3000,3);
				Joined[playerid] = 1;
				return 1;
         }
         case 2:
         {
              DisablePlayerRaceCheckpoint(playerid);
              PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
              SetPlayerRaceCheckpoint(playerid, 0,-1357.7117,2621.8223,51.8769,-1409.8826,2304.5452,54.4369,10);
              Stats[playerid] = 3;
              return 1;
         }
         case 3:
         {
              DisablePlayerRaceCheckpoint(playerid);
              PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
              SetPlayerRaceCheckpoint(playerid, 0,-1409.8826,2304.5452,54.4369,-1325.1870,1991.3693,52.0603,10);
              Stats[playerid] = 4;
              return 1;
         }
         case 4:
         {
              DisablePlayerRaceCheckpoint(playerid);
              PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
              SetPlayerRaceCheckpoint(playerid, 0,-1325.1870,1991.3693,52.0603,-1182.4658,1815.4572,40.6895,10);
              Stats[playerid] = 5;
              return 1;
         }
         case 5:
         {
              DisablePlayerRaceCheckpoint(playerid);
              PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
              SetPlayerRaceCheckpoint(playerid, 0,-1182.4658,1815.4572,40.6895,0.0,0.0,0.0,10);
              Stats[playerid] = 6;
              return 1;
         }
         case 6:
         {
            static place;
            place++;
            DisablePlayerRaceCheckpoint(playerid);
            PlayerPlaySound(playerid, 1056, 0.0, 0.0 , 10.0);
            Stats[playerid] = 7;
            new name[MAX_PLAYER_NAME], string[100];
            GetPlayerName(playerid, name, sizeof(name));
            format(string, sizeof(string), "[RACE]: %s has finished Drag Race 1 on %d%s place!", name, place, (place == 1) ? ("st") : (place == 2) ? ("nd") : (place == 3) ? ("rd") : ("th"));
            SendClientMessageToAll(green, string);
            Started[playerid] = 0;
            Joined[playerid] = 0;
            return 1;
         }
    }
    return 1;
}
Please help me its very important!
Reply
#2

you are using "player" while you did not specify this ID in the timer..
what you need is a timer without a "playerid" parameter

so change
pawn Код:
forward RaceStart(playerid);
to
pawn Код:
forward RaceStart();
and your race start callback to this:
pawn Код:
public RaceStart()
{
    for(new playerid=0; playerid<MAX_PLAYERS; playerid++)
    {
        if(IsPlayerInRaceCheckpoint(playerid))
        {
            DisablePlayerRaceCheckpoint(playerid);
            PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
            SetPlayerRaceCheckpoint(playerid, 0,-1037.9878,2709.0464,45.4293,-1357.7117,2621.8223,51.8769,10);
            Stats[playerid] = 2;
            GameTextForPlayer(playerid,"~g~!!! GO GO GO !!!",3000,3);
        }
    }
}
Reply
#3

Still nothing happens!
Reply
#4

Please help me!

(Sry for bump/spam)
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)