20.06.2014, 18:57
Galera to precisando de ajuda eu to com um FS de sistema de corrida que peguei de um outro servidor da internet o nome й RraceES mas nгo consigo fazer com que quando a pessoa der /entrarrace nгo consiga usar mas nenhum comando a nгo ser /Srace, se tiver como alguйm me ajudar ae porfavor.
Esse й o cуdigo que eu vi que meu gm usa para bloquear os teles quando vai /x1.
Aqui ta o FS quem puder me ajudar ae por favor
Esse й o cуdigo que eu vi que meu gm usa para bloquear os teles quando vai /x1.
pawn Код:
new bool:EventoProibirTele = false;
new EventoAtivo;
new NoEvento[MAX_PLAYERS];
if(EventoProibirTele == true && NoEvento[playerid] == 1 && EventoAtivo == 1) return
pawn Код:
#include <a_samp>
#include <Dini>
#include <zcmd>
#define ForEach(%0,%1) \
for(new %0 = 0; %0 != %1; %0++) if(IsPlayerConnected(%0) && !IsPlayerNPC(%0))
#define Loop(%0,%1) \
for(new %0 = 0; %0 != %1; %0++)
#define IsOdd(%1) \
((%1) & 1)
#define ConvertTime(%0,%1,%2,%3,%4) \
new \
Float: %0 = floatdiv(%1, 60000) \
;\
%2 = floatround(%0, floatround_tozero); \
%3 = floatround(floatmul(%0 - %2, 60), floatround_tozero); \
%4 = floatround(floatmul(floatmul(%0 - %2, 60) - %3, 1000), floatround_tozero)
#define function%0(%1) \
forward%0(%1); public%0(%1)
#define MAX_RACE_CHECKPOINTS_EACH_RACE \
120
#define MAX_RACES \
100
#define COUNT_DOWN_TILL_RACE_START \
30 // seconds
#define MAX_RACE_TIME \
300 // seconds
#define RACE_CHECKPOINT_SIZE \
12.0
#define DEBUG_RACE \
0
#define DIALOG_RACES \
350
#define IsPlayerInMiniGame \
GetPVarInt(playerid, "PlayerInMiniGame") == 1
//#define RACE_IN_OTHER_WORLD // Uncomment to enable
#define GREY \
0xAFAFAFAA
#define GREEN \
0x9FFF00FF
#define RED \
0xE60000FF
#define YELLOW \
0xFFFF00AA
#define WHITE \
0xFFFFFFAA
new
vNames[212][] =
{
{"Landstalker"},
{"Bravura"},
{"Buffalo"},
{"Linerunner"},
{"Perrenial"},
{"Sentinel"},
{"Dumper"},
{"Firetruck"},
{"Trashmaster"},
{"Stretch"},
{"Manana"},
{"Infernus"},
{"Voodoo"},
{"Pony"},
{"Mule"},
{"Cheetah"},
{"Ambulance"},
{"Leviathan"},
{"Moonbeam"},
{"Esperanto"},
{"Taxi"},
{"Washington"},
{"Bobcat"},
{"Mr Whoopee"},
{"BF Injection"},
{"Hunter"},
{"Premier"},
{"Enforcer"},
{"Securicar"},
{"Banshee"},
{"Predator"},
{"Bus"},
{"Rhino"},
{"Barracks"},
{"Hotknife"},
{"Trailer 1"},
{"Previon"},
{"Coach"},
{"Cabbie"},
{"Stallion"},
{"Rumpo"},
{"RC Bandit"},
{"Romero"},
{"Packer"},
{"Monster"},
{"Admiral"},
{"Squalo"},
{"Seasparrow"},
{"Pizzaboy"},
{"Tram"},
{"Trailer 2"},
{"Turismo"},
{"Speeder"},
{"Reefer"},
{"Tropic"},
{"Flatbed"},
{"Yankee"},
{"Caddy"},
{"Solair"},
{"Berkley's RC Van"},
{"Skimmer"},
{"PCJ-600"},
{"Faggio"},
{"Freeway"},
{"RC Baron"},
{"RC Raider"},
{"Glendale"},
{"Oceanic"},
{"Sanchez"},
{"Sparrow"},
{"Patriot"},
{"Quad"},
{"Coastguard"},
{"Dinghy"},
{"Hermes"},
{"Sabre"},
{"Rustler"},
{"ZR-350"},
{"Walton"},
{"Regina"},
{"Comet"},
{"BMX"},
{"Burrito"},
{"Camper"},
{"Marquis"},
{"Baggage"},
{"Dozer"},
{"Maverick"},
{"News Chopper"},
{"Rancher"},
{"FBI Rancher"},
{"Virgo"},
{"Greenwood"},
{"Jetmax"},
{"Hotring"},
{"Sandking"},
{"Blista Compact"},
{"Police Maverick"},
{"Boxville"},
{"Benson"},
{"Mesa"},
{"RC Goblin"},
{"Hotring Racer A"},
{"Hotring Racer B"},
{"Bloodring Banger"},
{"Rancher"},
{"Super GT"},
{"Elegant"},
{"Journey"},
{"Bike"},
{"Mountain Bike"},
{"Beagle"},
{"Cropdust"},
{"Stunt"},
{"Tanker"},
{"Roadtrain"},
{"Nebula"},
{"Majestic"},
{"Buccaneer"},
{"Shamal"},
{"Hydra"},
{"FCR-900"},
{"NRG-500"},
{"HPV1000"},
{"Cement Truck"},
{"Tow Truck"},
{"Fortune"},
{"Cadrona"},
{"FBI Truck"},
{"Willard"},
{"Forklift"},
{"Tractor"},
{"Combine"},
{"Feltzer"},
{"Remington"},
{"Slamvan"},
{"Blade"},
{"Freight"},
{"Streak"},
{"Vortex"},
{"Vincent"},
{"Bullet"},
{"Clover"},
{"Sadler"},
{"Firetruck LA"},
{"Hustler"},
{"Intruder"},
{"Primo"},
{"Cargobob"},
{"Tampa"},
{"Sunrise"},
{"Merit"},
{"Utility"},
{"Nevada"},
{"Yosemite"},
{"Windsor"},
{"Monster A"},
{"Monster B"},
{"Uranus"},
{"Jester"},
{"Sultan"},
{"Stratum"},
{"Elegy"},
{"Raindance"},
{"RC Tiger"},
{"Flash"},
{"Tahoma"},
{"Savanna"},
{"Bandito"},
{"Freight Flat"},
{"Streak Carriage"},
{"Kart"},
{"Mower"},
{"Duneride"},
{"Sweeper"},
{"Broadway"},
{"Tornado"},
{"AT-400"},
{"DFT-30"},
{"Huntley"},
{"Stafford"},
{"BF-400"},
{"Newsvan"},
{"Tug"},
{"Trailer 3"},
{"Emperor"},
{"Wayfarer"},
{"Euros"},
{"Hotdog"},
{"Club"},
{"Freight Carriage"},
{"Trailer 3"},
{"Andromada"},
{"Dodo"},
{"RC Cam"},
{"Launch"},
{"Police Car (LSPD)"},
{"Police Car (SFPD)"},
{"Police Car (LVPD)"},
{"Police Ranger"},
{"Picador"},
{"S.W.A.T. Van"},
{"Alpha"},
{"Phoenix"},
{"Glendale"},
{"Sadler"},
{"Luggage Trailer A"},
{"Luggage Trailer B"},
{"Stair Trailer"},
{"Boxville"},
{"Farm Plow"},
{"Utility Trailer"}
},
BuildRace,
BuildRaceType,
BuildVehicle,
BuildCreatedVehicle,
BuildModeVID,
BuildName[30],
bool: BuildTakeVehPos,
BuildVehPosCount,
bool: BuildTakeCheckpoints,
BuildCheckPointCount,
RaceBusy = 0x00,
RaceName[30],
RaceVehicle,
RaceType,
TotalCP,
Float: RaceVehCoords[2][4],
Float: CPCoords[MAX_RACE_CHECKPOINTS_EACH_RACE][4],
CreatedRaceVeh[MAX_PLAYERS],
Index,
PlayersCount[2],
CountTimer,
CountAmount,
bool: Joined[MAX_PLAYERS],
RaceTick,
RaceStarted,
CPProgess[MAX_PLAYERS],
Position,
FinishCount,
JoinCount,
rCounter,
RaceTime,
Text: RaceInfo[MAX_PLAYERS],
InfoTimer[MAX_PLAYERS],
RacePosition[MAX_PLAYERS],
RaceNames[MAX_RACES][128],
TotalRaces,
bool: AutomaticRace,
TimeProgress
;
public OnFilterScriptExit()
{
BuildCreatedVehicle = (BuildCreatedVehicle == 0x01) ? (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00) : (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00);
KillTimer(rCounter);
KillTimer(CountTimer);
Loop(i, MAX_PLAYERS)
{
DisablePlayerRaceCheckpoint(i);
TextDrawDestroy(RaceInfo[i]);
DestroyVehicle(CreatedRaceVeh[i]);
Joined[i] = false;
SetPVarInt(i, "JoinedToRRAce", false);
KillTimer(InfoTimer[i]);
}
JoinCount = 0;
FinishCount = 0;
TimeProgress = 0;
AutomaticRace = false;
return 1;
}
CMD:buildrace(playerid, params[])
{
if(BuildRace != 0) return SendClientMessage(playerid, RED, "<!> Ya se estб construyendo una carrera");
if(RaceBusy == 0x01) return SendClientMessage(playerid, RED, "<!> Espera a que acabe la carrera primero");
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, RED, "<!> Por favor, primero bajate del vehнculo");
BuildRace = playerid+1;
ShowDialog(playerid, 599);
return 1;
}
CMD:ssdstartrace(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "<!> No eres administrador!");
if(IsPlayerInMiniGame) return SendClientMessage(playerid, 0xFF4500FF, "Estбs en un minijuego, usa /salir");
if(AutomaticRace == true) return SendClientMessage(playerid, RED, "<!> No es posible, el modo automatico estб activado");
if(BuildRace != 0) return SendClientMessage(playerid, RED, "<!> Se estб construyendo una carrera");
if(RaceBusy == 0x01 || RaceStarted == 1) return SendClientMessage(playerid, RED, "<!> Hay una carrera en curso. Espera a que acabe");
if(isnull(params)) return SendClientMessage(playerid, RED, "<!> /startrace [racename]");
LoadRace(playerid, params);
return 1;
}
CMD:sdstoprace(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "<!> No eres administrador!");
if(IsPlayerInMiniGame) return SendClientMessage(playerid, 0xFF4500FF, "Estбs en un minijuego, usa /salir");
if(RaceBusy == 0x00 || RaceStarted == 0) return SendClientMessage(playerid, RED, "<!> No hay ninguna carrera activa!");
SendClientMessageToAll(RED, ">> An admin stopped the current race!");
return StopRace();
}
CMD:dsdjoinrace(playerid, params[])
{
if(RaceStarted == 1) return SendClientMessage(playerid, RED, "<!> La carrera ya ha empezado, espera a que acabe");
if(RaceBusy == 0x00) return SendClientMessage(playerid, RED, "<!> No hay ninguna carrera para unirte");
if(IsPlayerInMiniGame) return SendClientMessage(playerid, 0xFF4500FF, "Estбs en un minijuego, usa /salir");
if(Joined[playerid] == true) return SendClientMessage(playerid, RED, "<!> Ya estбs en una carrera!");
if(IsPlayerInAnyVehicle(playerid)) return SetTimerEx("SetupRaceForPlayer", 2500, 0, "e", playerid), RemovePlayerFromVehicle(playerid), SetPVarInt(playerid, "JoinedToRRAce", true), Joined[playerid] = true;
SetupRaceForPlayer(playerid);
Joined[playerid] = true;
SetPVarInt(playerid, "JoinedToRRAce", true);
return 1;
}
CMD:dsdstartautorace(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "<!> No eres administrador!");
if(RaceBusy == 0x01 || RaceStarted == 1) return SendClientMessage(playerid, RED, "<!> Hay una carrera activada. Espera a que acabe!");
if(AutomaticRace == true) return SendClientMessage(playerid, RED, "<!> El modo automбtico ya estб activado. Si se desea desactivar /stopautorace!");
LoadRaceNames();
LoadAutoRace(RaceNames[random(TotalRaces)]);
AutomaticRace = true;
SendClientMessage(playerid, GREEN, ">> Has iniciado la autocarrera. El filterscript elejirб carreras al azar!");
return 1;
}
CMD:dsdstopautorace(playerid, params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, RED, "<!> No eres administrador!");
if(AutomaticRace == false) return SendClientMessage(playerid, RED, "<!> Ya estб desactivado!");
AutomaticRace = false;
return 1;
}
CMD:dsexitrace(playerid, params[])
{
if(Joined[playerid] == true)
{
JoinCount--;
Joined[playerid] = false;
SetPVarInt(playerid, "JoinedToRRAce", false);
DestroyVehicle(CreatedRaceVeh[playerid]);
DisablePlayerRaceCheckpoint(playerid);
TextDrawHideForPlayer(playerid, RaceInfo[playerid]);
CPProgess[playerid] = 0;
KillTimer(InfoTimer[playerid]);
TogglePlayerControllable(playerid, true);
SetCameraBehindPlayer(playerid);
#if defined RACE_IN_OTHER_WORLD
SetPlayerVirtualWorld(playerid, 0);
#endif
} else return SendClientMessage(playerid, RED, "<!> No estбs en ninguna carrera");
return 1;
}
public OnPlayerEnterRaceCheckpoint(playerid)
{
if(CPProgess[playerid] == TotalCP -1)
{
new
TimeStamp,
TotalRaceTime,
string[256],
rFile[256],
pName[MAX_PLAYER_NAME],
rTime[3],
Prize[2],
TempTotalTime,
TempTime[3]
;
Position++;
GetPlayerName(playerid, pName, sizeof(pName));
TimeStamp = GetTickCount();
TotalRaceTime = TimeStamp - RaceTick;
ConvertTime(var, TotalRaceTime, rTime[0], rTime[1], rTime[2]);
switch(Position)
{
case 1: Prize[0] = (random(random(5000)) + 10000), Prize[1] = 10;
case 2: Prize[0] = (random(random(4500)) + 9000), Prize[1] = 9;
case 3: Prize[0] = (random(random(4000)) + 8000), Prize[1] = 8;
case 4: Prize[0] = (random(random(3500)) + 7000), Prize[1] = 7;
case 5: Prize[0] = (random(random(3000)) + 6000), Prize[1] = 6;
case 6: Prize[0] = (random(random(2500)) + 5000), Prize[1] = 5;
case 7: Prize[0] = (random(random(2000)) + 4000), Prize[1] = 4;
case 8: Prize[0] = (random(random(1500)) + 3000), Prize[1] = 3;
case 9: Prize[0] = (random(random(1000)) + 2000), Prize[1] = 2;
default: Prize[0] = random(random(1000)), Prize[1] = 1;
}
format(string, sizeof(string), ">> {00CCFF}%s {FFFFFF}ha terminado la carrera en la posiciуn {00CCFF}#%d", pName, Position);
SendClientMessageToAll(WHITE, string);
format(string, sizeof(string), " - Tiempo: {FFFF00}%d:%d.%d.", rTime[0], rTime[1], rTime[2]);
SendClientMessageToAll(WHITE, string);
format(string, sizeof(string), " - Premio: {FFFF00}$%d y +%d Score.", Prize[0], Prize[1]);
SendClientMessageToAll(WHITE, string);
if(FinishCount <= 5)
{
format(rFile, sizeof(rFile), "/rRaceSystem/%s.RRACE", RaceName);
format(string, sizeof(string), "BestRacerTime_%d", TimeProgress);
TempTotalTime = dini_Int(rFile, string);
ConvertTime(var1, TempTotalTime, TempTime[0], TempTime[1], TempTime[2]);
if(TotalRaceTime <= dini_Int(rFile, string) || TempTotalTime == 0)
{
dini_IntSet(rFile, string, TotalRaceTime);
format(string, sizeof(string), "BestRacer_%d", TimeProgress);
if(TempTotalTime != 0) format(string, sizeof(string), ">> {00CCFF}%s {FFFFFF}ha echo un nuevo record en la carrera {00CCFF}%s {FFFFFF}con {00CCFF}%d segundos en la posiciуn {00CCFF}#%d", pName, dini_Get(rFile, string), -(rTime[1] - TempTime[1]), TimeProgress+1);
else format(string, sizeof(string), ">> {00CCFF}%s ha hecho un nuevo record de posiciуn {00CCFF}#%d", pName, TimeProgress+1);
SendClientMessageToAll(GREEN, " ");
SendClientMessageToAll(GREEN, string);
SendClientMessageToAll(GREEN, " ");
format(string, sizeof(string), "BestRacer_%d", TimeProgress);
dini_Set(rFile, string, pName);
TimeProgress++;
}
}
FinishCount++;
GivePlayerMoney(playerid, Prize[0]);
SetPlayerScore(playerid, GetPlayerScore(playerid) + Prize[1]);
DisablePlayerRaceCheckpoint(playerid);
CPProgess[playerid]++;
if(FinishCount >= JoinCount) return StopRace();
}
else
{
CPProgess[playerid]++;
CPCoords[CPProgess[playerid]][3]++;
RacePosition[playerid] = floatround(CPCoords[CPProgess[playerid]][3], floatround_floor);
SetCP(playerid, CPProgess[playerid], CPProgess[playerid]+1, TotalCP, RaceType);
PlayerPlaySound(playerid, 1137, 0.0, 0.0, 0.0);
}
return 1;
}
public OnPlayerDisconnect(playerid)
{
if(Joined[playerid] == true)
{
JoinCount--;
Joined[playerid] = false;
SetPVarInt(playerid, "JoinedToRRAce", false);
DestroyVehicle(CreatedRaceVeh[playerid]);
DisablePlayerRaceCheckpoint(playerid);
TextDrawHideForPlayer(playerid, RaceInfo[playerid]);
CPProgess[playerid] = 0;
KillTimer(InfoTimer[playerid]);
#if defined RACE_IN_OTHER_WORLD
SetPlayerVirtualWorld(playerid, 0);
#endif
}
TextDrawDestroy(RaceInfo[playerid]);
if(BuildRace == playerid+1) BuildRace = 0;
return 1;
}
public OnPlayerConnect(playerid)
{
RaceInfo[playerid] = TextDrawCreate(488.199737, 317.916625, " ");
TextDrawLetterSize(RaceInfo[playerid], 0.449999, 1.600000);
TextDrawAlignment(RaceInfo[playerid], 1);
TextDrawColor(RaceInfo[playerid], -1);
TextDrawSetShadow(RaceInfo[playerid], 0);
TextDrawSetOutline(RaceInfo[playerid], 1);
TextDrawBackgroundColor(RaceInfo[playerid], 255);
TextDrawFont(RaceInfo[playerid], 1);
TextDrawSetProportional(RaceInfo[playerid], 58);
return 1;
}
public OnPlayerDeath(playerid)
{
if(Joined[playerid] == true)
{
JoinCount--;
Joined[playerid] = false;
SetPVarInt(playerid, "JoinedToRRAce", false);
DestroyVehicle(CreatedRaceVeh[playerid]);
DisablePlayerRaceCheckpoint(playerid);
TextDrawHideForPlayer(playerid, RaceInfo[playerid]);
CPProgess[playerid] = 0;
KillTimer(InfoTimer[playerid]);
#if defined RACE_IN_OTHER_WORLD
SetPlayerVirtualWorld(playerid, 0);
#endif
}
if(BuildRace == playerid+1) BuildRace = 0;
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch(dialogid)
{
case 599:
{
if(!response) return BuildRace = 0;
switch(listitem)
{
case 0: BuildRaceType = 0;
case 1: BuildRaceType = 3;
}
ShowDialog(playerid, 600);
}
case 600..601:
{
if(!response) return ShowDialog(playerid, 599);
if(!strlen(inputtext)) return ShowDialog(playerid, 601);
if(strlen(inputtext) < 1 || strlen(inputtext) > 20) return ShowDialog(playerid, 601);
strmid(BuildName, inputtext, 0, strlen(inputtext), sizeof(BuildName));
ShowDialog(playerid, 602);
}
case 602..603:
{
if(!response) return ShowDialog(playerid, 600);
if(!strlen(inputtext)) return ShowDialog(playerid, 603);
if(!IsNumeric(inputtext))
{
if(!IsValidVehicle(strval(inputtext))) return ShowDialog(playerid, 603);
new
Float: pPos[4]
;
GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
GetPlayerFacingAngle(playerid, pPos[3]);
BuildModeVID = strval(inputtext);
BuildCreatedVehicle = (BuildCreatedVehicle == 0x01) ? (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00) : (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00);
BuildVehicle = CreateVehicle(strval(inputtext), pPos[0], pPos[1], pPos[2], pPos[3], random(126), random(126), (60 * 60));
PutPlayerInVehicle(playerid, BuildVehicle, 0);
BuildCreatedVehicle = 0x01;
ShowDialog(playerid, 604);
}
else
{
if(!IsValidVehicle(ReturnVehicleID(inputtext))) return ShowDialog(playerid, 603);
new
Float: pPos[4]
;
GetPlayerPos(playerid, pPos[0], pPos[1], pPos[2]);
GetPlayerFacingAngle(playerid, pPos[3]);
BuildModeVID = ReturnVehicleID(inputtext);
BuildCreatedVehicle = (BuildCreatedVehicle == 0x01) ? (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00) : (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00);
BuildVehicle = CreateVehicle(ReturnVehicleID(inputtext), pPos[0], pPos[1], pPos[2], pPos[3], random(126), random(126), (60 * 60));
PutPlayerInVehicle(playerid, BuildVehicle, 0);
BuildCreatedVehicle = 0x01;
ShowDialog(playerid, 604);
}
}
case 604:
{
if(!response) return ShowDialog(playerid, 602);
SendClientMessage(playerid, GREEN, ">> Ir a la lнnea de salida de la izquierda y pulsa 'KEY_FIRE' y hacer lo mismo con el bloque de camino.");
SendClientMessage(playerid, GREEN, " - Cuando se hace esto, verб un cuadro de diбlogo para continuar.");
BuildVehPosCount = 0;
BuildTakeVehPos = true;
}
case 605:
{
if(!response) return ShowDialog(playerid, 604);
SendClientMessage(playerid, GREEN, ">> Comience a tomar los puestos de control ahora pulsando 'KEY_FIRE'.");
SendClientMessage(playerid, GREEN, " - IMPORTANTE: Presione 'ENTER' cuando haya terminado con los puntos de control! Si no reacciona presiona una y otra vez.");
BuildCheckPointCount = 0;
BuildTakeCheckpoints = true;
}
case 606:
{
if(!response) return ShowDialog(playerid, 606);
BuildRace = 0;
BuildCheckPointCount = 0;
BuildVehPosCount = 0;
BuildTakeCheckpoints = false;
BuildTakeVehPos = false;
BuildCreatedVehicle = (BuildCreatedVehicle == 0x01) ? (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00) : (DestroyVehicle(BuildVehicle), BuildCreatedVehicle = 0x00);
}
}
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new
string[256],
rNameFile[256],
rFile[256],
Float: vPos[4]
;
if(newkeys & KEY_FIRE)
{
if(BuildRace == playerid+1)
{
if(BuildTakeVehPos == true)
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, RED, ">> Se necesita estar en un vehнculo");
format(rFile, sizeof(rFile), "/rRaceSystem/%s.RRACE", BuildName);
GetVehiclePos(GetPlayerVehicleID(playerid), vPos[0], vPos[1], vPos[2]);
GetVehicleZAngle(GetPlayerVehicleID(playerid), vPos[3]);
dini_Create(rFile);
dini_IntSet(rFile, "vModel", BuildModeVID);
dini_IntSet(rFile, "rType", BuildRaceType);
format(string, sizeof(string), "vPosX_%d", BuildVehPosCount), dini_FloatSet(rFile, string, vPos[0]);
format(string, sizeof(string), "vPosY_%d", BuildVehPosCount), dini_FloatSet(rFile, string, vPos[1]);
format(string, sizeof(string), "vPosZ_%d", BuildVehPosCount), dini_FloatSet(rFile, string, vPos[2]);
format(string, sizeof(string), "vAngle_%d", BuildVehPosCount), dini_FloatSet(rFile, string, vPos[3]);
format(string, sizeof(string), ">> Vehicle Pos '%d' has been taken.", BuildVehPosCount+1);
SendClientMessage(playerid, YELLOW, string);
BuildVehPosCount++;
}
if(BuildVehPosCount >= 2)
{
BuildVehPosCount = 0;
BuildTakeVehPos = false;
ShowDialog(playerid, 605);
}
if(BuildTakeCheckpoints == true)
{
//if(BuildCheckPointCount > MAX_RACE_CHECKPOINTS_EACH_RACE) return SendClientMessage(playerid, RED, ">> Llegу a la mбxima cantidad de puntos de control!");
//if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, RED, ">> Se necesita estar en un vehнculo");
format(rFile, sizeof(rFile), "/rRaceSystem/%s.RRACE", BuildName);
GetVehiclePos(GetPlayerVehicleID(playerid), vPos[0], vPos[1], vPos[2]);
new string1[64];
format(string1, sizeof(string1), "CP_%d_PosX", BuildCheckPointCount);
dini_FloatSet(rFile, string1, vPos[0]);
new string2[64];
format(string2, sizeof(string2), "CP_%d_PosY", BuildCheckPointCount);
dini_FloatSet(rFile, string2, vPos[1]);
new string3[64];
format(string3, sizeof(string3), "CP_%d_PosZ", BuildCheckPointCount);
dini_FloatSet(rFile, string3, vPos[2]);
new string4[145];
format(string4, sizeof(string4), ">> Punto de control {00CCFF}#%d {FFFF00}ha sido puesto correctamente!", BuildCheckPointCount+1);
SendClientMessage(playerid, YELLOW, string4);
BuildCheckPointCount++;
}
}
}
if(newkeys & KEY_SECONDARY_ATTACK)
{
if(BuildTakeCheckpoints == true)
{
ShowDialog(playerid, 606);
format(rNameFile, sizeof(rNameFile), "/rRaceSystem/RaceNames/RaceNames.txt");
TotalRaces = dini_Int(rNameFile, "TotalRaces");
TotalRaces++;
dini_IntSet(rNameFile, "TotalRaces", TotalRaces);
format(string, sizeof(string), "Race_%d", TotalRaces-1);
format(rFile, sizeof(rFile), "/rRaceSystem/%s.RRACE", BuildName);
dini_Set(rNameFile, string, BuildName);
dini_IntSet(rFile, "TotalCP", BuildCheckPointCount);
Loop(x, 5)
{
format(string, sizeof(string), "BestRacerTime_%d", x);
dini_Set(rFile, string, "0");
format(string, sizeof(string), "BestRacer_%d", x);
dini_Set(rFile, string, "noone");
}
}
}
return 1;
}
function LoadRaceNames()
{
new
rNameFile[64],
string[64]
;
format(rNameFile, sizeof(rNameFile), "/rRaceSystem/RaceNames/RaceNames.txt");
TotalRaces = dini_Int(rNameFile, "TotalRaces");
Loop(x, TotalRaces)
{
format(string, sizeof(string), "Race_%d", x), strmid(RaceNames[x], dini_Get(rNameFile, string), 0, 20, sizeof(RaceNames));
printf(">> Loaded Races: %s", RaceNames[x]);
}
return 1;
}
function LoadAutoRace(rName[])
{
new
rFile[256],
string[256]
;
format(rFile, sizeof(rFile), "/rRaceSystem/%s.RRACE", rName);
if(!dini_Exists(rFile)) return printf("Race \"%s\" doesn't exist!", rName);
strmid(RaceName, rName, 0, strlen(rName), sizeof(RaceName));
RaceVehicle = dini_Int(rFile, "vModel");
RaceType = dini_Int(rFile, "rType");
TotalCP = dini_Int(rFile, "TotalCP");
#if DEBUG_RACE == 1
printf("VehicleModel: %d", RaceVehicle);
printf("RaceType: %d", RaceType);
printf("TotalCheckpoints: %d", TotalCP);
#endif
Loop(x, 2)
{
format(string, sizeof(string), "vPosX_%d", x), RaceVehCoords[x][0] = dini_Float(rFile, string);
format(string, sizeof(string), "vPosY_%d", x), RaceVehCoords[x][1] = dini_Float(rFile, string);
format(string, sizeof(string), "vPosZ_%d", x), RaceVehCoords[x][2] = dini_Float(rFile, string);
format(string, sizeof(string), "vAngle_%d", x), RaceVehCoords[x][3] = dini_Float(rFile, string);
#if DEBUG_RACE == 1
printf("VehiclePos %d: %f, %f, %f, %f", x, RaceVehCoords[x][0], RaceVehCoords[x][1], RaceVehCoords[x][2], RaceVehCoords[x][3]);
#endif
}
Loop(x, TotalCP)
{
format(string, sizeof(string), "CP_%d_PosX", x), CPCoords[x][0] = dini_Float(rFile, string);
format(string, sizeof(string), "CP_%d_PosY", x), CPCoords[x][1] = dini_Float(rFile, string);
format(string, sizeof(string), "CP_%d_PosZ", x), CPCoords[x][2] = dini_Float(rFile, string);
#if DEBUG_RACE == 1
printf("RaceCheckPoint %d: %f, %f, %f", x, CPCoords[x][0], CPCoords[x][1], CPCoords[x][2]);
#endif
}
Position = 0;
FinishCount = 0;
JoinCount = 0;
Loop(x, 2) PlayersCount[x] = 0;
CountAmount = COUNT_DOWN_TILL_RACE_START;
RaceTime = MAX_RACE_TIME;
RaceBusy = 0x01;
CountTimer = SetTimer("CountTillRace", 999, 1);
TimeProgress = 0;
CallRemoteFunction("OnRaceStart", "");
return 1;
}
function LoadRace(playerid, rName[])
{
new
rFile[256],
string[256]
;
format(rFile, sizeof(rFile), "/rRaceSystem/%s.RRACE", rName);
if(!dini_Exists(rFile)) return SendClientMessage(playerid, RED, "<!> La carrera no existe"), printf("La carrera \"%s\" no existe!", rName);
strmid(RaceName, rName, 0, strlen(rName), sizeof(RaceName));
RaceVehicle = dini_Int(rFile, "vModel");
RaceType = dini_Int(rFile, "rType");
TotalCP = dini_Int(rFile, "TotalCP");
#if DEBUG_RACE == 1
printf("VehicleModel: %d", RaceVehicle);
printf("RaceType: %d", RaceType);
printf("TotalCheckpoints: %d", TotalCP);
#endif
Loop(x, 2)
{
format(string, sizeof(string), "vPosX_%d", x), RaceVehCoords[x][0] = dini_Float(rFile, string);
format(string, sizeof(string), "vPosY_%d", x), RaceVehCoords[x][1] = dini_Float(rFile, string);
format(string, sizeof(string), "vPosZ_%d", x), RaceVehCoords[x][2] = dini_Float(rFile, string);
format(string, sizeof(string), "vAngle_%d", x), RaceVehCoords[x][3] = dini_Float(rFile, string);
#if DEBUG_RACE == 1
printf("VehiclePos %d: %f, %f, %f, %f", x, RaceVehCoords[x][0], RaceVehCoords[x][1], RaceVehCoords[x][2], RaceVehCoords[x][3]);
#endif
}
Loop(x, TotalCP)
{
format(string, sizeof(string), "CP_%d_PosX", x), CPCoords[x][0] = dini_Float(rFile, string);
format(string, sizeof(string), "CP_%d_PosY", x), CPCoords[x][1] = dini_Float(rFile, string);
format(string, sizeof(string), "CP_%d_PosZ", x), CPCoords[x][2] = dini_Float(rFile, string);
#if DEBUG_RACE == 1
printf("RaceCheckPoint %d: %f, %f, %f", x, CPCoords[x][0], CPCoords[x][1], CPCoords[x][2]);
#endif
}
Position = 0;
FinishCount = 0;
JoinCount = 0;
Loop(x, 2) PlayersCount[x] = 0;
Joined[playerid] = true;
SetPVarInt(playerid, "JoinedToRRAce", true);
CountAmount = COUNT_DOWN_TILL_RACE_START;
RaceTime = MAX_RACE_TIME;
RaceBusy = 0x01;
TimeProgress = 0;
SetupRaceForPlayer(playerid);
CountTimer = SetTimer("CountTillRace", 999, 1);
CallRemoteFunction("OnRaceStart", "");
return 1;
}
function SetCP(playerid, PrevCP, NextCP, MaxCP, Type)
{
if(Type == 0)
{
if(NextCP == MaxCP) SetPlayerRaceCheckpoint(playerid, 1, CPCoords[PrevCP][0], CPCoords[PrevCP][1], CPCoords[PrevCP][2], CPCoords[NextCP][0], CPCoords[NextCP][1], CPCoords[NextCP][2], RACE_CHECKPOINT_SIZE);
else SetPlayerRaceCheckpoint(playerid, 0, CPCoords[PrevCP][0], CPCoords[PrevCP][1], CPCoords[PrevCP][2], CPCoords[NextCP][0], CPCoords[NextCP][1], CPCoords[NextCP][2], RACE_CHECKPOINT_SIZE);
}
else if(Type == 3)
{
if(NextCP == MaxCP) SetPlayerRaceCheckpoint(playerid, 4, CPCoords[PrevCP][0], CPCoords[PrevCP][1], CPCoords[PrevCP][2], CPCoords[NextCP][0], CPCoords[NextCP][1], CPCoords[NextCP][2], RACE_CHECKPOINT_SIZE);
else SetPlayerRaceCheckpoint(playerid, 3, CPCoords[PrevCP][0], CPCoords[PrevCP][1], CPCoords[PrevCP][2], CPCoords[NextCP][0], CPCoords[NextCP][1], CPCoords[NextCP][2], RACE_CHECKPOINT_SIZE);
}
return 1;
}
function SetupRaceForPlayer(playerid)
{
CPProgess[playerid] = 0;
TogglePlayerControllable(playerid, false);
CPCoords[playerid][3] = 0;
SetCP(playerid, CPProgess[playerid], CPProgess[playerid]+1, TotalCP, RaceType);
if(IsOdd(playerid)) Index = 1;
else Index = 0;
switch(Index)
{
case 0:
{
if(PlayersCount[0] == 1)
{
RaceVehCoords[0][0] -= (6 * floatsin(-RaceVehCoords[0][3], degrees));
RaceVehCoords[0][1] -= (6 * floatcos(-RaceVehCoords[0][3], degrees));
CreatedRaceVeh[playerid] = CreateVehicle(RaceVehicle, RaceVehCoords[0][0], RaceVehCoords[0][1], RaceVehCoords[0][2]+2, RaceVehCoords[0][3], random(126), random(126), (60 * 60));
SetPlayerPos(playerid, RaceVehCoords[0][0], RaceVehCoords[0][1], RaceVehCoords[0][2]+2);
SetPlayerFacingAngle(playerid, RaceVehCoords[0][3]);
PutPlayerInVehicle(playerid, CreatedRaceVeh[playerid], 0);
Camera(playerid, RaceVehCoords[0][0], RaceVehCoords[0][1], RaceVehCoords[0][2], RaceVehCoords[0][3], 20);
}
}
case 1:
{
if(PlayersCount[1] == 1)
{
RaceVehCoords[1][0] -= (6 * floatsin(-RaceVehCoords[1][3], degrees));
RaceVehCoords[1][1] -= (6 * floatcos(-RaceVehCoords[1][3], degrees));
CreatedRaceVeh[playerid] = CreateVehicle(RaceVehicle, RaceVehCoords[1][0], RaceVehCoords[1][1], RaceVehCoords[1][2]+2, RaceVehCoords[1][3], random(126), random(126), (60 * 60));
SetPlayerPos(playerid, RaceVehCoords[1][0], RaceVehCoords[1][1], RaceVehCoords[1][2]+2);
SetPlayerFacingAngle(playerid, RaceVehCoords[1][3]);
PutPlayerInVehicle(playerid, CreatedRaceVeh[playerid], 0);
Camera(playerid, RaceVehCoords[1][0], RaceVehCoords[1][1], RaceVehCoords[1][2], RaceVehCoords[1][3], 20);
}
}
}
switch(Index)
{
case 0:
{
if(PlayersCount[0] != 1)
{
CreatedRaceVeh[playerid] = CreateVehicle(RaceVehicle, RaceVehCoords[0][0], RaceVehCoords[0][1], RaceVehCoords[0][2]+2, RaceVehCoords[0][3], random(126), random(126), (60 * 60));
SetPlayerPos(playerid, RaceVehCoords[0][0], RaceVehCoords[0][1], RaceVehCoords[0][2]+2);
SetPlayerFacingAngle(playerid, RaceVehCoords[0][3]);
PutPlayerInVehicle(playerid, CreatedRaceVeh[playerid], 0);
Camera(playerid, RaceVehCoords[0][0], RaceVehCoords[0][1], RaceVehCoords[0][2], RaceVehCoords[0][3], 20);
PlayersCount[0] = 1;
}
}
case 1:
{
if(PlayersCount[1] != 1)
{
CreatedRaceVeh[playerid] = CreateVehicle(RaceVehicle, RaceVehCoords[1][0], RaceVehCoords[1][1], RaceVehCoords[1][2]+2, RaceVehCoords[1][3], random(126), random(126), (60 * 60));
SetPlayerPos(playerid, RaceVehCoords[1][0], RaceVehCoords[1][1], RaceVehCoords[1][2]+2);
SetPlayerFacingAngle(playerid, RaceVehCoords[1][3]);
PutPlayerInVehicle(playerid, CreatedRaceVeh[playerid], 0);
Camera(playerid, RaceVehCoords[1][0], RaceVehCoords[1][1], RaceVehCoords[1][2], RaceVehCoords[1][3], 20);
PlayersCount[1] = 1;
}
}
}
new
string[128]
;
#if defined RACE_IN_OTHER_WORLD
SetPlayerVirtualWorld(playerid, 10);
#endif
InfoTimer[playerid] = SetTimerEx("TextInfo", 500, 1, "e", playerid);
if(JoinCount == 1) format(string, sizeof(string), "~r~~h~Nombre: ~w~%s~n~~r~~h~Checkpoint: ~w~%d/%d~n~~r~~h~Tiempo: ~w~%s~n~~r~~h~Posicion: ~w~1/1", RaceName, CPProgess[playerid], TotalCP, TimeConvert(RaceTime));
else format(string, sizeof(string), "~r~~h~Nombre: ~w~%s~n~~r~~h~Checkpoint: ~w~%d/%d~n~~r~~h~Tiempo: ~w~%s~n~~r~~h~Posicion: ~w~%d/%d", RaceName, CPProgess[playerid], TotalCP, TimeConvert(RaceTime), RacePosition[playerid], JoinCount);
TextDrawSetString(RaceInfo[playerid], string);
TextDrawShowForPlayer(playerid, RaceInfo[playerid]);
JoinCount++;
return 1;
}
function CountTillRace()
{
switch(CountAmount)
{
case 0:
{
ForEach(i, MAX_PLAYERS)
{
if(Joined[i] == false)
{
new
string[128]
;
format(string, sizeof(string), ">> No te puedes unir a la carrera \"%s\". El tiempo terminу!", RaceName);
SendClientMessage(i, RED, string);
}
}
StartRace();
}
case 1..5:
{
new
string[10]
;
format(string, sizeof(string), "~b~%d", CountAmount);
ForEach(i, MAX_PLAYERS)
{
if(Joined[i] == true)
{
GameTextForPlayer(i, string, 999, 5);
PlayerPlaySound(i, 1056, 0.0, 0.0, 0.0);
}
}
}
case 60, 50, 40, 30, 20, 10:
{
new
string[145]
;
format(string, sizeof(string), ">> Faltan {00CCFF}%d {9FFF00}segundos para que la carrera {00CCFF}%s {9FFF00}empieze! Escribe {00CCFF}/joinrace", CountAmount, RaceName);
SendClientMessageToAll(GREEN, string);
}
}
return CountAmount--;
}
function StartRace()
{
ForEach(i, MAX_PLAYERS)
{
if(Joined[i] == true)
{
TogglePlayerControllable(i, true);
PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
CallRemoteFunction("OnRaceEnd", "");
GameTextForPlayer(i, "~g~VAMOS !", 2000, 5);
SetCameraBehindPlayer(i);
}
}
rCounter = SetTimer("RaceCounter", 900, 1);
RaceTick = GetTickCount();
RaceStarted = 1;
KillTimer(CountTimer);
return 1;
}
function StopRace()
{
KillTimer(rCounter);
RaceStarted = 0;
RaceTick = 0;
RaceBusy = 0x00;
CallRemoteFunction("OnRaceEnd", "");
JoinCount = 0;
FinishCount = 0;
TimeProgress = 0;
ForEach(i, MAX_PLAYERS)
{
if(Joined[i] == true)
{
DisablePlayerRaceCheckpoint(i);
DestroyVehicle(CreatedRaceVeh[i]);
Joined[i] = false;
SetPVarInt(i, "JoinedToRRAce", false);
TextDrawHideForPlayer(i, RaceInfo[i]);
CPProgess[i] = 0;
KillTimer(InfoTimer[i]);
}
}
SendClientMessageToAll(YELLOW, ">> La carrera ha terminado!");
if(AutomaticRace == true) LoadRaceNames(), LoadAutoRace(RaceNames[random(TotalRaces)]);
return 1;
}
function RaceCounter()
{
if(RaceStarted == 1)
{
RaceTime--;
if(JoinCount <= 0)
{
StopRace();
SendClientMessageToAll(RED, ">> La carrera finalizу.. No hay nadie en la carrera!");
}
}
if(RaceTime <= 0)
{
StopRace();
}
return 1;
}
function TextInfo(playerid)
{
new
string[128]
;
if(JoinCount == 1) format(string, sizeof(string), "~r~~h~Nombre: ~w~%s~n~~r~~h~Checkpoint: ~w~%d/%d~n~~r~~h~Tiempo: ~w~%s~n~~r~~h~Posicion: ~w~1/1", RaceName, CPProgess[playerid], TotalCP, TimeConvert(RaceTime));
else format(string, sizeof(string), "~r~~h~Nombre: ~w~%s~n~~r~~h~Checkpoint: ~w~%d/%d~n~~r~~h~Tiempo: ~w~%s~n~~r~~h~Posicion: ~w~%d/%d", RaceName, CPProgess[playerid], TotalCP, TimeConvert(RaceTime), RacePosition[playerid], JoinCount);
TextDrawSetString(RaceInfo[playerid], string);
TextDrawShowForPlayer(playerid, RaceInfo[playerid]);
}
function Camera(playerid, Float:X, Float:Y, Float:Z, Float:A, Mul)
{
SetPlayerCameraLookAt(playerid, X, Y, Z);
SetPlayerCameraPos(playerid, X + (Mul * floatsin(-A, degrees)), Y + (Mul * floatcos(-A, degrees)), Z+6);
}
function IsPlayerInRace(playerid)
{
if(Joined[playerid] == true) return true;
else return false;
}
function ShowDialog(playerid, dialogid)
{
switch(dialogid)
{
case 599: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_LIST, CreateCaption("Construir una nueva carrera"), "\
Carrera Normal\n\
Carrera por el aire", ">>", "Salir");
case 600: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, CreateCaption("Construir una nueva carrera (Paso 1/4)"), "\
Step 1:\n\
********\n\
Welcome to wizard 'Build New Race'.\n\
Before getting started, I need to know the name (e.g. SFRace) of the to save it under.\n\n\
>> Give the NAME below and press 'Next' to continue.", "Next", "Back");
case 601: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, CreateCaption("Construir una nueva carrera (Paso 1/4)"), "\
ERROR: Name too short or too long! (min. 1 - max. 20)\n\n\n\
Step 1:\n\
********\n\
Welcome to wizard 'Build New Race'.\n\
Before getting started, I need to know the name (e.g. SFRace) of the to save it under.\n\n\
>> Give the NAME below and press 'Next' to continue.", "Next", "Back");
case 602: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, CreateCaption("Construir una nueva carrera (Paso 2/4)"), "\
Step 2:\n\
********\n\
Please give the ID or NAME of the vehicle that's going to be used in the race you are creating now.\n\n\
>> Give the ID or NAME of the vehicle below and press 'Next' to continue. 'Back' to change something.", "Next", "Back");
case 603: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_INPUT, CreateCaption("Build New Race (Step 2/4)"), "\
ERROR: Invalid Vehilce ID/Name\n\n\n\
Step 2:\n\
********\n\
Please give the ID or NAME of the vehicle that's going to be used in the race you are creating now.\n\n\
>> Give the ID or NAME of the vehicle below and press 'Next' to continue. 'Back' to change something.", "Next", "Back");
case 604: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, CreateCaption("Construir una nueva carrera (Paso 3/4)"),
"\
Step 3:\n\
********\n\
We are almost done! Now go to the start line where the first and second car should stand.\n\
Note: When you click 'OK' you will be free. Use 'KEY_FIRE' to set the first position and second position.\n\
Note: After you got these positions you will automaticly see a dialog to continue the wizard.\n\n\
>> Press 'OK' to do the things above. 'Back' to change something.", "OK", "Back");
case 605: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, CreateCaption("Construir una nueva carrera (Paso 4/4)"),
"\
Step 4:\n\
********\n\
Welcome to the last stap. In this stap you have to set the checkpoints; so if you click 'OK' you can set the checkpoints.\n\
You can set the checkpoints with 'KEY_FIRE'. Each checkpoint you set will save.\n\
You have to press 'ENTER' button when you're done with everything. You race is aviable then!\n\n\
>> Press 'OK' to do the things above. 'Back' to change something.", "OK", "Back");
case 606: ShowPlayerDialog(playerid, dialogid, DIALOG_STYLE_MSGBOX, CreateCaption("Build New Race (Done)"),
"\
You have created your race and it's ready to use now.\n\n\
>> Press 'Finish' to finish. 'Exit' - Has no effect.", "Finish", "Exit");
}
return 1;
}
stock IsNumeric(string[])
{
for (new i = 0, j = strlen(string); i < j; i++)
{
if (string[i] > '9' || string[i] < '0') return 0;
}
return 1;
}
CreateCaption(arguments[])
{
new
string[128 char]
;
format(string, sizeof(string), "RyDeR's Race System - %s", arguments);
return string;
}
stock IsValidVehicle(vehicleid)
{
if(vehicleid < 400 || vehicleid > 611) return false;
else return true;
}
ReturnVehicleID(vName[])
{
Loop(x, 211)
{
if(strfind(vNames[x], vName, true) != -1)
return x + 400;
}
return -1;
}
TimeConvert(seconds)
{
new tmp[16];
new minutes = floatround(seconds/60);
seconds -= minutes*60;
format(tmp, sizeof(tmp), "%d:%02d", minutes, seconds);
return tmp;
}