Jump to content

[GM]NRG Race


Guest farse

Recommended Posts

Am reusit sa rezolv bug-urile.

Fa un update la postul tau.

/*
-------------------------------------------------------------------
--------------------------FARSE------------------------------------
-------------------------------------------------------------------
*/

#include <a_samp>
#pragma tabsize 0

#define COLOR_BLUE 0x000ecaAA
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_YELLOW 0xFFFF00AA


new gProgressTwo[MAX_PLAYERS];
new onceTwo[MAX_PLAYERS];
new gPositionTwo;
new gCountdowntimerTwo;
new gCountdownTwo;

new gTimeTwo;
new gTimerTwo;
new gRaceStillInProgressTwo;
new gCheckTimeTwo;
#define MAX_CHECKPOINTSTWO 35

new Float:gRaceCheckpointsTwo[MAX_CHECKPOINTSTWO][10] = {
{2465.968994,-1660.231323,12.276421,23.0},//1
{2413.828369,-1658.252686,12.382813,23.0},//2
{2303.655029,-1659.450439,13.476613,23.0},//3
{2196.926758,-1639.022217,14.312500,23.0},//4
{1996.422363,-1622.989136,12.546875,23.0},//5
{1932.648560,-1617.910400,12.539082,23.0},//7
{1853.574829,-1613.469360,12.390608,23.0},//8
{1826.353027,-1615.203979,12.385198,23.0},//9
{1821.600464,-1575.916260,12.355615,23.0},//10
{1828.757690,-1554.067627,12.370012,23.0},
{1843.231934,-1482.535522,12.370775,23.0},
{1898.395386,-1460.637817,12.382813,23.0},
{1959.481445,-1449.564453,12.549465,23.0},
{1962.781128,-1403.960449,12.577248,23.0},
{1897.272583,-1357.397461,12.509418,23.0},
{2052.366211,-1337.951904,22.820313,23.0},//10
{2170.658936,-1341.698242,22.828125,23.0},//11
{2236.743896,-1342.619263,30.271870,23.0},//12
{2244.935059,-1383.205811,22.832008,23.0},//13
{2279.246826,-1373.169434,23.000313,23.0},//14
{2279.512207,-1351.971069,28.148438,23.0},//14
{2295.099609,-1354.380859,28.148438,23.0},//15
{2296.039307,-1373.999756,23.043247,23.0},//16
{2327.042480,-1384.776489,22.847219,23.0},//16
{2342.080322,-1421.376099,22.828125,23.0},//17
{2311.069092,-1484.864502,22.411690,23.0},//18
{2297.377930,-1524.363159,25.875000,23.0},//19
{2343.977783,-1569.009033,22.838345,23.0},//20
{2344.318115,-1625.633423,16.691774,23.0},//21
{2344.472656,-1681.376221,12.359398,23.0},//22
{2349.645752,-1731.509888,12.382813,23.0},//23
{2370.389160,-1729.067749,12.382813,23.0},//24
{2433.280273,-1730.795410,12.546181,23.0},//25
{2478.954834,-1724.184326,12.554682,23.0},//25
{2484.437256,-1674.049194,12.335947,23.0}//35

};

main()
{
	print("\n----------------------------------");
	print("  NRG RACE By Farse");
	print("     version 1.0:");
	print("        NRG RACE INTERATIVITY");
	print("----------------------------------\n");
}

public OnGameModeInit()
{
	print("Gamemode successfully loaded");
	SetGameModeText("NRG RACE");
	AddStaticVehicle(522,2504.912,-1665.003,13.052,89.0,-1,-1);
	AddStaticVehicle(522,2505.005,-1666.320,13.052,89.0,-1,-1);
	AddStaticVehicle(522,2505.196,-1667.542,13.052,89.0,-1,-1);
	AddStaticVehicle(522,2505.068,-1668.704,13.052,89.0,-1,-1);
	AddStaticVehicle(522,2505.154,-1670.169,13.052,89.0,-1,-1);
	AddStaticVehicle(522,2504.635,-1661.704,13.052,89.0,-1,-1);
	AddStaticVehicle(522,2502.000,-1660.175,13.052,89.0,-1,-1);
	AddStaticVehicle(522,2503.160,-1671.855,13.052,89.0,-1,-1);
	AddPlayerClass(124,2504.221,-1663.556,13.052,158.2551,0,0,0,0,0,0); //
	gTimeTwo = 0;
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
 	SetPlayerInterior(playerid,0);
	SetPlayerPos(playerid,2504.221,-1663.556,13.052);
	SetPlayerFacingAngle(playerid, 158.2551);
	SetPlayerCameraPos(playerid,2504.221,-1663.556,13.052);
	SetPlayerCameraLookAt(playerid,2504.221,-1663.556,13.052);
	return 1;
}

public OnGameModeExit()
{
	print("Gamemode successfully unloaded");
	return 1;
}

public OnPlayerConnect(playerid)
{
	new playername[256];
	GetPlayerName(playerid,playername,sizeof(playername));
	new welcomemsg[256];
	format(welcomemsg,sizeof(welcomemsg),"Welcome %s to the NRG RACE mode!",playername);
	SendClientMessage(playerid,COLOR_YELLOW,welcomemsg);
	return 1;
}

public OnPlayerDisconnect(playerid)
{
	printf("OnPlayerDisconnect(%d)", playerid);
	return 1;
}

public OnPlayerSpawn(playerid)
{
    SetPlayerInterior(playerid,0);
    gProgressTwo[playerid] = 0;
    SetPlayerCheckpoint(playerid,gRaceCheckpointsTwo[0][0],gRaceCheckpointsTwo[0][1],gRaceCheckpointsTwo[0][2],gRaceCheckpointsTwo[0][3]);




	return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    if(killerid == INVALID_PLAYER_ID) {
        SendDeathMessage(INVALID_PLAYER_ID,playerid,reason);

	} else {
	    	SendDeathMessage(killerid,playerid,reason);
			SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
			}

 	return 1;
}



	public OnPlayerEnterCheckpoint(playerid)
	{
	DisablePlayerCheckpoint(playerid);
	if (gProgressTwo[playerid] == MAX_CHECKPOINTSTWO-1){

						gPositionTwo++;

						new playername[MAX_PLAYER_NAME];
			  			new finishmessage[256];
  					    new finishtime[256];
  					    new Float:fMinutes;
  					    new Minutes;
  					    new Seconds;

						if (gTimeTwo != 0) {
	  					    fMinutes = gTimeTwo/60;
	  					    Minutes = floatround(fMinutes, floatround_floor);
	  					    Seconds = gTimeTwo-(Minutes*60);

							format(finishtime, sizeof(finishtime),"Ai terminat cursa in %d minute %d secunde.", Minutes, Seconds);
							SendClientMessage(playerid, COLOR_GREY, finishtime);
			  			}


			  			GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
			  			switch (gPositionTwo){
						  case 1:
						  {
						  	format(finishmessage, sizeof(finishmessage),"%s has won the race!", playername);
							GameTextForAll(finishmessage, 3000, 5);
							SetPlayerScore(playerid,GetPlayerScore(playerid)+5);
						  }
			  			case 2:
						  {
						  	format(finishmessage, sizeof(finishmessage),"%s o terminat %d nd", playername, gPositionTwo);
							GameTextForAll(finishmessage, 3000, 5);
							SetPlayerScore(playerid,GetPlayerScore(playerid)+4);
						  }
					    case 3:
						  {
						  	format(finishmessage, sizeof(finishmessage),"%s o terminat %d rd", playername, gPositionTwo);
							GameTextForAll(finishmessage, 3000, 5);
							SetPlayerScore(playerid,GetPlayerScore(playerid)+3);
						  }
					    default:
						  {
						  	format(finishmessage, sizeof(finishmessage),"%s o terminat %d th", playername, gPositionTwo);
							GameTextForAll(finishmessage, 3000, 5);
							SetPlayerScore(playerid,GetPlayerScore(playerid)+1);
						  }
						}
		}

	if (gProgressTwo[playerid] == 0)
	{
		if (onceTwo[playerid] == 0){
		SendClientMessage(playerid, COLOR_YELLOW, "Vrei sa incepi cursa?Scrie /STARTRACE pentru a incepe cursa.");
		onceTwo[playerid] = 1;
		}
		gProgressTwo[playerid]=0;
	}
	else
	{
	gProgressTwo[playerid]++;
	SetPlayerCheckpoint(playerid,gRaceCheckpointsTwo[gProgressTwo[playerid]][0],gRaceCheckpointsTwo[gProgressTwo[playerid]][1],gRaceCheckpointsTwo[gProgressTwo[playerid]][2],gRaceCheckpointsTwo[gProgressTwo[playerid]][3]); // ml
	if (gCheckTimeTwo > 10 || gCheckTimeTwo == 0){
	KillTimer(gRaceStillInProgressTwo);
	gCheckTimeTwo=1;
	gRaceStillInProgressTwo=SetTimer("CheckpointTimer", 1000, 1);
	}
	}
return 1;}
forward GettimerTwo();
public GettimerTwo() {
	gCountdownTwo--;

	if (gCountdownTwo >= 1){
	new message[256];
	format(message, sizeof(message),"%d", gCountdownTwo);
	GameTextForAll(message, 750, 5);
	}
	else {
	KillTimer(gCountdowntimerTwo);
 		for (new i = 0; i < MAX_PLAYERS; i++)
	    {
	    TogglePlayerControllable(i, 1);
	    }
	GameTextForAll("~w~GO", 2000, 5);
	gTimeTwo = 0;
	KillTimer(gTimerTwo);
	gTimerTwo=SetTimer("RaceTimer", 1000, 1);

	}
return 1;
	}
forward RaceTimer();
public RaceTimer() {
gTimeTwo++;
}
forward CheckpointTimer();
public CheckpointTimer() {
gCheckTimeTwo++;
}

forward EndGame();
public EndGame(){
GameModeExit();
}



public OnVehicleSpawn(vehicleid)
{
	printf("OnVehicleSpawn(%d)", vehicleid);
	return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
	printf("OnVehicleDeath(%d, %d)", vehicleid, killerid);
	return 1;
}


public OnPlayerCommandText(playerid, cmdtext[])
{

	if (strcmp(cmdtext, "/startrace", true)==0)
	{


	    if (gCheckTimeTwo > 30 || gCheckTimeTwo == 0 || IsPlayerAdmin(playerid) == 1)
		{
			gCountdownTwo=6;
   			gPositionTwo = 0;
		    gTimeTwo = 0;

			SendClientMessageToAll(COLOR_GREY, "Cursa a inceput");


				    for (new i = 0; i < MAX_PLAYERS; i++)
				    {
				    gProgressTwo[i] = 1;
				    SetPlayerCheckpoint(i,gRaceCheckpointsTwo[1][0],gRaceCheckpointsTwo[1][1],gRaceCheckpointsTwo[1][2],gRaceCheckpointsTwo[1][3]);
				    }

				    KillTimer(gCountdowntimerTwo);
				    gCountdowntimerTwo=SetTimer("GettimerTwo", 1000, 1);
				    }


			else {
		//race in progress msg

            SendClientMessage(playerid, COLOR_YELLOW, "Scuze cursa sa terminat.");
	            }
	    return 1;
	}

	if (strcmp(cmdtext, "/rescueme", true)==0)
	{
		gProgressTwo[playerid] = 1;
		SetPlayerCheckpoint(playerid,gRaceCheckpointsTwo[1][0],gRaceCheckpointsTwo[1][1],gRaceCheckpointsTwo[1][2],gRaceCheckpointsTwo[1][3]);
		SetPlayerPos(playerid,gRaceCheckpointsTwo[0][0],gRaceCheckpointsTwo[0][1],gRaceCheckpointsTwo[0][2]);
	}

	if (strcmp(cmdtext, "/help", true)==0)
	{
		SendClientMessage(playerid, COLOR_YELLOW, "Scrie /STARTRACE pentru a incepe cursa. SCRIE /RESCUEME dca ai pierdut.");
		SendClientMessage(playerid, COLOR_YELLOW, "Urmeaza checkponturile pentru a termina cursa.");
	}


// #include <votescript>

	printf("OnPlayerInfoChange(%d)");
	return 1;
}

Link to comment
Share on other sites

  • 1 year later...
  • 8 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.