15.10.2010, 15:43
(
Последний раз редактировалось Kitten; 12.09.2011 в 14:59.
)
This tutorial is old and some codes are not working it was made in 2010 when i was sorta a (newbie)
Race Tutorial The way i make my racesSimple 5 steps
Step1: Well you start off making a FS or a GM
Step2 : make a variable on top of your script named
pawn Код:
new Racer[MAX_PLAYERS];
pawn Код:
SetPlayerRaceCheckpoin(playerid, type, Float:x, Float:y, Float:z, Float:nextx, Float:nexty, Float:nextz, Float:size);
pawn Код:
Racer[playerid] = 1;
pawn Код:
public OnPlayerSpawn(playerid)
{
SetPlayerRaceCheckpoin(playerid, type, Float:x, Float:y, Float:z, Float:nextx, Float:nexty, Float:nextz, Float:size);
Racer[playerid] = 1;
return 1;
}
heres the
Step4: now make this on player enter race checkpoint
pawn Код:
public OnPlayerEnterRaceCheckpoint(playerid)
{
switch(Racer[playerid])
{
Step5: Now add your Race Checkpoint
example it is
pawn Код:
case 1:
{
DisablePlayerRaceCheckpoint(playerid);
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
SetPlayerRaceCheckpoint(playerid, type, Float:x, Float:y, Float:z, Float:nextx, Float:nexty, Float:nextz, Float:size);
Racer[playerid] = 2;
return 1;
}
and by the way for your last checkpoint have this as a extra bonus when a player wins like homo won 5th place or 1st
pawn Код:
case 10:
{
static place;
place++;
DisablePlayerRaceCheckpoint(playerid);
PlayerPlaySound(playerid, 1056, 0.0, 0.0 , 10.0);
SetPlayerRaceCheckpoint(playerid, type, Float:x, Float:y, Float:z, Float:nextx, Float:nexty, Float:nextz, Float:size);
Racer[playerid] = 4; // Change this to your last checkpoint
new name[MAX_PLAYER_NAME], string[100];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "Player %s Has Finshed Race [%d%s]", name, place, (place == 1) ? ("st") : (place == 2) ? ("nd") : (place == 3) ? ("rd") : ("th"));
SendClientMessageToAll(White, string);
DisablePlayerCheckpoint(playerid);
new currentveh;
currentveh = GetPlayerVehicleID(playerid);
DestroyVehicle(currentveh);
}
with a timer for Gamemode 4 min
Drunk Vision
Thanks i hope i helped
pawn Код:
#include <a_samp>
#define Red 0xFF0000FF
#define Grey 0xAFAFAFAA
#define Green 0x33AA33AA
#define Yellow 0xFFFF00AA
#define White 0xFFFFFFAA
#define Blue 0x0000BBAA
#define Lightblue 0x33CCFFAA
#define Orange 0xFF9900AA
#define Lime 0x10F441AA
#define Magenta 0xFF00FFFFT
#define Navy 0x000080AA
#define Aqua 0xF0F8FFAA
#define Crimson 0xDC143CAA
#define Black 0x000000AA
#define Brown 0XA52A2AAA
#define Gold 0xB8860BAA
#define Limegreen 0x32CD32AA
#pragma tabsize 0
#define COLOR_GREEN 0x33AA33AA
#define TEAM_RACER 0
forward One(playerid);
forward Two(playerid);
forward Three(playerid);
forward Four(playerid);
forward Five(playerid);
forward GoGoGo(playerid);
forward GameTime(playerid);
new gTeam[MAX_PLAYERS];
new Racer[MAX_PLAYERS];
new GameMinutes =4;
new GameSeconds =59;
new GameTimer;
new Text:Textdraw0;
// Cars
new TURISMO[1];
new TURISMO[2];
new TURISMO[3];
new TURISMO[4];
new TURISMO[5];
new TURISMO[6];
new TURISMO[7];
new TURISMO[8];
new TURISMO[9];
new TURISMO[10];
new TURISMO[11];
new TURISMO[12];
new TURISMO[13];
new TURISMO[14];
new TURISMO[15];
new TURISMO[16];
new TURISMO[17];
new TURISMO[18];
new TURISMO[19];
main()
{
print("\n----------------------------------");
print(" Test race");
print("----------------------------------\n");
}
public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
SetGameModeText("Test race-");
AddPlayerClass(29, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
TURISMO1 = AddStaticVehicle(451,1580.1036,930.3267,10.3795,88.0555,47,10); // turismo 1
TURISMO2 = AddStaticVehicle(451,1580.1801,936.2764,10.3793,91.9955,115,107); // turismo 2
TURISMO3 = AddStaticVehicle(451,1587.4896,936.4547,10.3790,92.0370,89,120); // turismo 3
TURISMO4 = AddStaticVehicle(451,1587.5153,930.1140,10.3781,87.3709,72,85); // turismo 4
TURISMO5 = AddStaticVehicle(451,1595.3516,936.5620,10.3787,86.8713,54,100); // turismo 5
TURISMO6 = AddStaticVehicle(451,1595.0507,931.0535,10.3787,86.8713,54,100); // turismo 6
TURISMO7 = AddStaticVehicle(451,1605.5587,930.4791,10.4856,86.8713,54,100); // turismo 7
TURISMO8 = AddStaticVehicle(451,1605.8248,935.3460,10.4857,86.8713,54,100); // turismo 8
TURISMO9 = AddStaticVehicle(451,1614.0858,935.7368,10.5522,86.8713,54,100); // turismo 9
TURISMO10 = AddStaticVehicle(451,1613.8562,931.5319,10.5522,86.8713,54,100); // turismo 10
TURISMO11 = AddStaticVehicle(451,1628.4114,930.7363,10.6700,86.8713,54,100); // turismo 11
TURISMO12 = AddStaticVehicle(451,1628.6840,935.7252,10.6701,86.8713,54,100); // turismo 12
TURISMO13 = AddStaticVehicle(451,1638.6200,935.1821,10.7505,86.8713,54,100); // turismo 13
TURISMO14 = AddStaticVehicle(451,1638.4059,931.2660,10.7505,86.8713,54,100); // turismo 14
TURISMO15 = AddStaticVehicle(451,1649.8406,930.6410,10.8431,86.8713,54,100); // turismo 15
TURISMO16 = AddStaticVehicle(451,1650.1477,936.2583,10.8431,86.8713,54,100); // turismo 16
TURISMO17 = AddStaticVehicle(451,1660.1869,935.7095,10.9244,86.8713,54,100); // turismo 17
TURISMO18 = AddStaticVehicle(451,1659.9515,931.4034,10.9244,86.8713,54,100); // turismo 18
GameTimer = SetTimer("GameTime",1000,1);
Textdraw0 = TextDrawCreate(86.000000,427.000000,"4:00");
TextDrawAlignment(Textdraw0,2);
TextDrawBackgroundColor(Textdraw0,0x000000ff);
TextDrawFont(Textdraw0,3);
TextDrawLetterSize(Textdraw0,0.499999,2.000000);
TextDrawColor(Textdraw0,0xffffffff);
TextDrawSetOutline(Textdraw0,1);
TextDrawSetProportional(Textdraw0,1);
TextDrawSetShadow(Textdraw0,1);
SetTimer("GameOver",300000,false);
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid,1984.4445,157.9501,55.9384);
SetPlayerCameraPos(playerid,1984.4445,160.9501,55.9384);
SetPlayerCameraLookAt(playerid,1984.4445,157.9501,55.9384);
SetPlayerFacingAngle(playerid,0.0);
return 1;
}
public OnPlayerConnect(playerid)
{
GameTextForPlayer(playerid, "~g~ Test Race-", 5000, 0);
if(gTeam[playerid] == TEAM_RACER)
{
GameTextForAll("~g~ Racer",5000,3);
gTeam[playerid] = TEAM_RACER;
SetPlayerTeam(playerid,0);
SetPlayerTime(playerid,0,0);
}
new pName[30], string[256];
GetPlayerName(playerid, pName, 30);
format(string, 256, "~g~Welcome ~n~~r~%s! To Race Example by Kitty", pName);
GameTextForAll(string,4000,1);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}
public OnPlayerSpawn(playerid)
{
SetPlayerRaceCheckpoint(playerid, 0,1566.2670,968.1899,10.3788,1541.1074,1038.7144,10.5273,10);
Racer[playerid] = 1;
SetPlayerTime(playerid,0,0);
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
SetPlayerDrunkLevel(playerid, 7000);
TogglePlayerControllable(playerid,0);
SetTimer("Five", 1000, 0);
SetTimer("Four", 2000, 0);
SetTimer("Three", 3000, 0);
SetTimer("Two", 4000, 0);
SetTimer("One", 5000, 0);
SetTimer("GoGoGo", 6000, 0);
TextDrawShowForPlayer(playerid,Textdraw0);
switch(random(18))
{
case 0:PutPlayerInVehicle(playerid,TURISMO1, 0);
case 1:PutPlayerInVehicle(playerid,TURISMO2, 0);
case 2:PutPlayerInVehicle(playerid,TURISMO3, 0);
case 3:PutPlayerInVehicle(playerid,TURISMO4, 0);
case 4:PutPlayerInVehicle(playerid,TURISMO5, 0);
case 5:PutPlayerInVehicle(playerid,TURISMO6, 0);
case 6:PutPlayerInVehicle(playerid,TURISMO7, 0);
case 7:PutPlayerInVehicle(playerid,TURISMO8, 0);
case 8:PutPlayerInVehicle(playerid,TURISMO9, 0);
case 9:PutPlayerInVehicle(playerid,TURISMO10, 0);
case 10:PutPlayerInVehicle(playerid,TURISMO11, 0);
case 11:PutPlayerInVehicle(playerid,TURISMO12, 0);
case 12:PutPlayerInVehicle(playerid,TURISMO13, 0);
case 13:PutPlayerInVehicle(playerid,TURISMO14, 0);
case 14:PutPlayerInVehicle(playerid,TURISMO15, 0);
case 15:PutPlayerInVehicle(playerid,TURISMO16, 0);
case 16:PutPlayerInVehicle(playerid,TURISMO17, 0);
case 17:PutPlayerInVehicle(playerid,TURISMO18, 0);
}
return 1;
}
public GameTime()
{
if(GameSeconds || GameMinutes)
{
GameSeconds--;
if(GameSeconds <= -1)
{
GameMinutes--;
GameSeconds=59;
}
new TimeString[14];
format(TimeString,sizeof(TimeString),"%02d:%02d",GameMinutes,GameSeconds);
TextDrawSetString(Textdraw0,TimeString);
}
return 1;
}
public One(playerid)
{
GameTextForAll("~w~1",2000,3);
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
return 1;
}
public Two(playerid)
{
GameTextForAll("~w~2",2000,3);
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
return 1;
}
public Three(playerid)
{
GameTextForAll("~w~3",2000,3);
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
return 1;
}
public Four(playerid)
{
GameTextForAll("~w~4",2000,3);
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
return 1;
}
public Five(playerid)
{
GameTextForAll("~w~5",2000,3);
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
return 1;
}
public GoGoGo(playerid)
{
GameTextForAll("~w~GO GO GO!",3000,3);
TogglePlayerControllable(playerid,1);
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 10.0);
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
switch(Racer[playerid])
{
case 1:
{
DisablePlayerRaceCheckpoint(playerid);
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
SetPlayerRaceCheckpoint(playerid, 0,1503.2065,958.5538,10.4067,1557.2222,910.5775,10.3780,10);
Racer[playerid] = 2;
return 1;
}
case 2:
{
DisablePlayerRaceCheckpoint(playerid);
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
SetPlayerRaceCheckpoint(playerid, 0,1569.2622,689.3107,10.3776,1505.5327,658.3589,10.4497,10);
Racer[playerid] = 3;
return 1;
}
case 3:
{
DisablePlayerRaceCheckpoint(playerid);
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
SetPlayerRaceCheckpoint(playerid, 0,1349.7750,705.1266,10.4149,1328.4138,821.4951,7.3387,10);
Racer[playerid] = 4;
return 1;
}
case 4:
{
DisablePlayerRaceCheckpoint(playerid);
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
SetPlayerRaceCheckpoint(playerid, 0,1125.9352,811.7488,10.4101,807.1027,675.1436,11.2626,10);
Racer[playerid] = 5;
return 1;
}
case 5:
{
DisablePlayerRaceCheckpoint(playerid);
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
SetPlayerRaceCheckpoint(playerid, 0,630.8825,681.5414,5.6024,464.9801,716.7991,5.5819,10);
Racer[playerid] = 6;
return 1;
}
case 6:
{
DisablePlayerRaceCheckpoint(playerid);
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
SetPlayerRaceCheckpoint(playerid, 0,387.4834,675.0266,12.1045,491.4214,513.0236,18.6282,10);
Racer[playerid] = 7;
return 1;
}
case 7:
{
DisablePlayerRaceCheckpoint(playerid);
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
SetPlayerRaceCheckpoint(playerid, 0,617.7587,320.2140,19.3585,496.4489,221.7117,12.3474,10);
Racer[playerid] = 8;
return 1;
}
case 8:
{
DisablePlayerRaceCheckpoint(playerid);
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
SetPlayerRaceCheckpoint(playerid, 0,356.2368,104.2745,4.5115,233.9318,-6.5190,1.5703,10);
Racer[playerid] = 9;
return 1;
}
case 9:
{
DisablePlayerRaceCheckpoint(playerid);
PlayerPlaySound(playerid, 1056, 0.0, 0.0, 10.0);
SetPlayerRaceCheckpoint(playerid, 1,232.1634,-161.3152,1.1359,360.8855,-393.8163,20.4167,10);
Racer[playerid] = 10;
return 1;
}
case 10:
{
static place;
place++;
DisablePlayerRaceCheckpoint(playerid);
PlayerPlaySound(playerid, 1056, 0.0, 0.0 , 10.0);
SetPlayerRaceCheckpoint(playerid, 1,60.8855,-393.8163,20.4167,0.0,0.0,0.0,10);
Racer[playerid] = 11;
new name[MAX_PLAYER_NAME], string[100];
GetPlayerName(playerid, name, sizeof(name));
format(string, sizeof(string), "Player %s Has Finshed Race [%d%s]", name, place, (place == 1) ? ("st") : (place == 2) ? ("nd") : (place == 3) ? ("rd") : ("th")); // how would i make it for all playrs go like player noob has finshed second player carbon has finshed 3rd
SendClientMessageToAll(White, string);
DisablePlayerCheckpoint(playerid);
new currentveh;
currentveh = GetPlayerVehicleID(playerid);
DestroyVehicle(currentveh);
}
}
return 1;
}
forward GameOver(playerid);
public GameOver(playerid)
{
SendRconCommand("gmx");
GameTextForPlayer(playerid,"~g~ Race passed ~w~+10000",6000,0);
GivePlayerMoney(playerid,10000);
KillTimer(GameTimer);
return 1;
}
Hope i helped again