14.01.2011, 14:42
Here is my code:
There is an error about "MountainCheckpoint+1"
pawn Код:
////////////////////////////////////////////////////////////////////////////////
//-------------------------------Mountain Race--------------------------------//
//------------------------------------By--------------------------------------//
//----------------------------------Vakho-------------------------------------//
////////////////////////////////////////////////////////////////////////////////
#include <a_samp>
new MountainCheckpoint[MAX_PLAYERS];
new Text:Textdraw0;
new Text:Textdraw01;
new Text:Textdraw1;
new Text:Textdraw2;
new Text:Textdraw3;
new Text:Textdraw4;
new Text:Textdraw5;
////////////////////////////////////////////////////////////////////////////////
#define winner_money 1000
////////////////////////////////////////////////////////////////////////////////
new Float:CheckPoints[40][3] =
{
{-2376.56079102,-2196.37548828,32.98622131},
{-2316.90234375,-2169.97705078,38.64624405},
{-2224.14794922,-2108.48730469,71.60419464},
{-2163.00097656,-2042.08044434,91.63574219},
{-2121.10424805,-1958.54431152,98.71120453},
{-2129.50903320,-1910.08056641,115.10286713},
{-2177.21337891,-2000.43969727,118.73865509},
{-2257.65454102,-2074.11083984,119.82920837},
{-2450.36938477,-2085.39111328,124.46894836},
{-2575.54785156,-2076.83154297,130.73474121},
{-2624.72216797,-2022.88940430,126.18408966},
{-2679.67822266,-1885.45385742,135.77619934},
{-2767.28662109,-1825.29223633,141.46330261},
{-2776.31835938,-1688.59130859,141.20094299},
{-2751.00634766,-1389.04724121,142.24172974},
{-2673.69360352,-1217.40185547,161.19935608},
{-2555.02075195,-1137.53173828,173.77552795},
{-2575.2026367188,-1164.7471923828,187.18154907227},
{-2608.92651367,-1279.94738770,219.19633484},
{-2670.15722656,-1363.37500000,250.42440796},
{-2622.95678711,-1363.60485840,262.11669922},
{-2531.61083984,-1300.08178711,270.09640503},
{-2434.06079102,-1272.29968262,290.37707520},
{-2338.22973633,-1316.46923828,309.67651367},
{-2495.96508789,-1406.08068848,344.79940796},
{-2571.34985352,-1505.74670410,358.67266846},
{-2429.01074219,-1395.79394531,359.55859375},
{-2285.73706055,-1423.54223633,356.65335083},
{-2190.26049805,-1714.29357910,376.22222900},
{-2247.33618164,-1506.23132324,378.56478882},
{-2359.46728516,-1447.57336426,383.39346313},
{-2478.86083984,-1477.38378906,390.59039307},
{-2527.40869141,-1652.81762695,400.42272949},
{-2501.81469727,-1769.28161621,402.38702393},
{-2439.56665039,-1808.95727539,410.13232422},
{-2441.39282227,-1719.48217773,432.39294434},
{-2353.23120117,-1816.81933594,432.48126221},
{-2279.45800781,-1726.20068359,470.28945923},
{-2300.5498046875,-1672.7099609375,483.31066895},
{-2300.5498046875,-1672.7099609375,483.31066895}
};
////////////////////////////////////////////////////////////////////////////////
new count = 3;
new counttimer;
forward CountDown();
////////////////////////////////////////////////////////////////////////////////
new Player_CheckPoint[MAX_PLAYERS];
////////////////////////////////////////////////////////////////////////////////
new bool:IsRaceRunning = false;
////////////////////////////////////////////////////////////////////////////////
new WinnerName[MAX_PLAYER_NAME];
////////////////////////////////////////////////////////////////////////////////
new stringwin[64];
////////////////////////////////////////////////////////////////////////////////
#if defined FILTERSCRIPT
////////////////////////////////////////////////////////////////////////////////
#endif
////////////////////////////////////////////////////////////////////////////////
public OnPlayerEnterRaceCheckpoint(playerid)
{
if(IsRaceRunning == true) { Player_CheckPoint[playerid]++; }
if(Player_CheckPoint[playerid] < 38 && IsRaceRunning == true)
{
DisablePlayerRaceCheckpoint(playerid);
SetPlayerRaceCheckpoint(playerid,0,CheckPoints[Player_CheckPoint[playerid]][0],CheckPoints[Player_CheckPoint[playerid]][1],CheckPoints[Player_CheckPoint[playerid]][2],CheckPoints[Player_CheckPoint[playerid]+1][0],CheckPoints[Player_CheckPoint[playerid]+1][1],CheckPoints[Player_CheckPoint[playerid]+1][2],5.5);
/////asdadgsd
return 1;
}
if(Player_CheckPoint[playerid] == 38 && IsRaceRunning == true)
{
DisablePlayerRaceCheckpoint(playerid);
SetPlayerRaceCheckpoint(playerid,1,CheckPoints[Player_CheckPoint[playerid]][0],CheckPoints[Player_CheckPoint[playerid]][1],CheckPoints[Player_CheckPoint[playerid]][2],CheckPoints[Player_CheckPoint[playerid]+1][0],CheckPoints[Player_CheckPoint[playerid]+1][1],CheckPoints[Player_CheckPoint[playerid]+1][2],5.5);
return 1;
}
if(Player_CheckPoint[playerid] == 39 && IsRaceRunning == true)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
DisablePlayerRaceCheckpoint(i);
}
GetPlayerName(playerid,WinnerName,sizeof(WinnerName));
format(stringwin,sizeof(stringwin),"The race is over, %s has won and achieved $%d!",WinnerName,winner_money);
SendClientMessageToAll(0xFF0000FF,stringwin);
GivePlayerMoney(playerid,winner_money);
TextDrawHideForAll(Textdraw0);
TextDrawDestroy(Textdraw0);
TextDrawHideForAll(Textdraw01);
TextDrawDestroy(Textdraw01);
TextDrawHideForAll(Textdraw1);
TextDrawDestroy(Textdraw1);
TextDrawHideForAll(Textdraw2);
TextDrawDestroy(Textdraw2);
TextDrawHideForAll(Textdraw3);
TextDrawDestroy(Textdraw3);
TextDrawHideForAll(Textdraw4);
TextDrawDestroy(Textdraw4);
TextDrawHideForAll(Textdraw5);
TextDrawDestroy(Textdraw5);
IsRaceRunning = false;
return 1;
}
return 1;
}
////////////////////////////////////////////////////////////////////////////////
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp(cmdtext, "/race", true) == 0 && IsPlayerAdmin(playerid))
{
CountDown();
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
Player_CheckPoint[i] = 0;
SetPlayerRaceCheckpoint(i,0,CheckPoints[0][0],CheckPoints[0][1],CheckPoints[0][2],CheckPoints[1][0],CheckPoints[1][1],CheckPoints[1][2],5.5);
IsRaceRunning = true;
}
}
}
if(strcmp(cmdtext, "/trace", true) == 0) //&& IsPlayerAdmin(playerid))
{
SetPlayerPos(playerid,-2404.9462890625,-2179.810546875,32.938289642334);
SetPlayerFacingAngle(playerid,180);
SetCameraBehindPlayer(playerid);
return 1;
}
return 0;
}
////////////////////////////////////////////////////////////////////////////////
public CountDown()
{
if(count <= 0)
{
GameTextForAll("~r~ GO", 5000, 5);
KillTimer(counttimer);
count = 5;
return 1;
}
else
{
new str[128];
format(str, sizeof str, "~g~ %d", count);
GameTextForAll(str, 500, 5);
counttimer = SetTimer("CountDown", 1000, 0);
count--;
}
return 1;
}
////////////////////////////////////////////////////////////////////////////////
public OnFilterScriptInit()
{
Textdraw0 = TextDrawCreate(500.000000, 130.000000, "--------------------");
TextDrawBackgroundColor(Textdraw0, 255);
TextDrawFont(Textdraw0, 1);
TextDrawLetterSize(Textdraw0, 0.459999, 1.000000);
TextDrawColor(Textdraw0, 16777215);
TextDrawSetOutline(Textdraw0, 1);
TextDrawSetProportional(Textdraw0, 1);
Textdraw01 = TextDrawCreate(554.000000, 150.000000,"0");
TextDrawBackgroundColor(Textdraw01, 255);
TextDrawFont(Textdraw01, 1);
TextDrawLetterSize(Textdraw01, 0.339999, 1.000000);
TextDrawColor(Textdraw01, 16711935);
TextDrawSetOutline(Textdraw01, 1);
TextDrawSetProportional(Textdraw01, 1);
Textdraw1 = TextDrawCreate(554.000000, 150.000000,"0");
TextDrawBackgroundColor(Textdraw1, 255);
TextDrawFont(Textdraw1, 1);
TextDrawLetterSize(Textdraw1, 0.339999, 1.000000);
TextDrawColor(Textdraw1, 16711935);
TextDrawSetOutline(Textdraw1, 1);
TextDrawSetProportional(Textdraw1, 1);
Textdraw2 = TextDrawCreate(648.000000, 120.000000, "[");
TextDrawBackgroundColor(Textdraw2, 255);
TextDrawFont(Textdraw2, 3);
TextDrawLetterSize(Textdraw2, 0.000000, 6.299999);
TextDrawColor(Textdraw2, -1);
TextDrawSetOutline(Textdraw2, 1);
TextDrawSetProportional(Textdraw2, 0);
TextDrawUseBox(Textdraw2, 1);
TextDrawBoxColor(Textdraw2, 75);
TextDrawTextSize(Textdraw2, 493.000000, 60.000000);
Textdraw3 = TextDrawCreate(501.000000, 124.000000, "Checkpoints Picked Up");
TextDrawBackgroundColor(Textdraw3, 255);
TextDrawFont(Textdraw3, 1);
TextDrawLetterSize(Textdraw3, 0.339999, 1.000000);
TextDrawColor(Textdraw3, -65281);
TextDrawSetOutline(Textdraw3, 1);
TextDrawSetProportional(Textdraw3, 1);
Textdraw4 = TextDrawCreate(569.000000, 150.000000, "/");
TextDrawBackgroundColor(Textdraw4, 255);
TextDrawFont(Textdraw4, 1);
TextDrawLetterSize(Textdraw4, 0.339999, 1.000000);
TextDrawColor(Textdraw4, 16777215);
TextDrawSetOutline(Textdraw4, 1);
TextDrawSetProportional(Textdraw4, 1);
Textdraw5 = TextDrawCreate(576.000000, 150.000000, "02");
TextDrawBackgroundColor(Textdraw5, 255);
TextDrawFont(Textdraw5, 1);
TextDrawLetterSize(Textdraw5, 0.339999, 1.000000);
TextDrawColor(Textdraw5, -16776961);
TextDrawSetOutline(Textdraw5, 1);
TextDrawSetProportional(Textdraw5, 1);
AddStaticVehicleEx(419,-2401.66943359,-2172.90405273,33.21906281,0.00000000,-1,-1,15); //Esperanto
AddStaticVehicleEx(405,-2387.77124023,-2173.41943359,33.28906250,0.00000000,-1,-1,15); //Sentinel
AddStaticVehicleEx(421,-2380.72998047,-2173.14575195,33.28906250,0.00000000,-1,-1,15); //Washington
AddStaticVehicleEx(489,-2388.55175781,-2188.49389648,35.41047668,90.00000000,-1,-1,15); //Rancher
CreateObject(16092,-2300.92407227,-1671.51965332,482.65609741,0.00000000,0.00000000,296.00000000); //object(des_pipestrut05) (1)
CreateObject(3861,-2398.05639648,-2195.04882812,33.46139526,0.00000000,0.00000000,30.00000000); //object(marketstall01_sfxrf) (1)
CreateObject(8558,-2387.92260742,-2170.73706055,33.81060410,0.00000000,0.00000000,0.00000000); //object(vgshseing28) (1)
CreateObject(3380,-2106.67285156,-1923.26318359,102.04016113,0.00000000,0.00000000,336.00000000); //object(ce_hairpinl) (1)
CreateObject(1002,-2398.28125000,-2195.91162109,33.10699081,0.00000000,0.00000000,354.00000000); //object(spl_b_bar_m) (1)
CreateObject(1010,-2398.74877930,-2196.49707031,33.10699081,0.00000000,0.00000000,300.00000000); //object(nto_b_tw) (1)
CreateObject(1153,-2398.43652344,-2196.22802734,32.72425461,0.00000000,0.00000000,210.00000000); //object(fbmp_a_f) (1)
CreateObject(1180,-2398.12060547,-2196.71362305,34.42935181,0.00000000,0.00000000,30.00000000); //object(rbmp_lr_rem1) (1)
CreateObject(2465,-2396.99536133,-2195.42480469,33.35194016,0.00000000,0.00000000,0.00000000); //object(model_box2) (1)
CreateObject(3567,-2387.61425781,-2189.02246094,33.16780853,0.00000000,0.00000000,89.99996948); //object(lasnfltrail) (1)
CreateObject(5153,-2398.46752930,-2189.55200195,32.99992752,0.00000000,0.00000000,0.00000000); //object(stuntramp7_las2) (1)
CreateObject(5153,-2398.46752930,-2188.35302734,32.99992752,0.00000000,0.00000000,0.00000000); //object(stuntramp7_las2) (2)
CreateObject(8990,-2402.72802734,-2168.34423828,32.99203110,0.00000000,0.00000000,0.00000000); //object(bush11_lvs) (1)
CreateObject(8990,-2389.71972656,-2168.55786133,32.99203110,0.00000000,0.00000000,0.00000000); //object(bush11_lvs) (2)
CreateObject(8990,-2376.17846680,-2168.51513672,33.05426025,0.00000000,0.00000000,0.00000000); //object(bush11_lvs) (3)
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
public OnPlayerUpdate(playerid)
{
format(MountainCheckpoint,2,"%d",MountainCheckpoint[playerid]);
format(MountainCheckpoint,sizeof(MountainCheckpoint),"%d",MountainCheckpoint);
TextDrawShowForPlayer(playerid, Textdraw1);
TextDrawShowForPlayer(playerid, Textdraw0);
TextDrawShowForPlayer(playerid, Textdraw2);
TextDrawShowForPlayer(playerid, Textdraw3);
TextDrawShowForPlayer(playerid, Textdraw4);
TextDrawShowForPlayer(playerid, Textdraw5);
if(IsRaceRunning == true) { Player_CheckPoint[playerid]++; }
if(Player_CheckPoint[playerid] < 38 && IsRaceRunning == true)
{
Textdraw1 = TextDrawCreate(554.000000, 150.000000,MountainCheckpoint+1);
TextDrawBackgroundColor(Textdraw1, 255);
TextDrawFont(Textdraw1, 1);
TextDrawLetterSize(Textdraw1, 0.339999, 1.000000);
TextDrawColor(Textdraw1, 16711935);
TextDrawSetOutline(Textdraw1, 1);
TextDrawSetProportional(Textdraw1, 1);
return 1;
}
return 0;
}