Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*----------------------------------------------------------------------------*\
- =======================================
- D_Races
- =======================================
- Descricao:
- Funções para sua criação de Corridas dinâmicas
- Obeservação:
- Podem haver Bugs(Muitos), estou postando apenas para verem como,
- está ficando a mesma.
- Esta versão está compativel com minha GameMode de FreeRoam,
- então a menos que edite a mesma, não funcionara com você.
- Aguarde a versão 0.2 para poder ultilizar
- Creditos:
- Dayvison - Criacao da include.
- Versão:
- 0.1 Alpha, open source to #SSGames
- Funcoes:
- Criadas:
- Race_Stop(raceid,bool:restart = false);
- Race_Create(name[]);
- Race_Destroy(raceid);
- Race_Exists(raceid);
- Race_IsActive(raceid);
- Race_AddCheckPoint(raceid,Float:x,Float:y,Float:z);
- Race_AddSpawn(raceid,Float:x,Float:y,Float:z,Float:ang);
- Race_GetNumSpawns(raceid);
- Race_GetNumCheckPoints(raceid);
- Race_SetWorld(raceid,world);
- Race_GetWorld(raceid);
- Race_SetInterior(raceid,interior);
- Race_GetInterior(raceid);
- Race_SetLaps(raceid,laps);
- Race_GetLaps(raceid);
- Race_SetMaxTime(raceid,time);
- Race_GetMaxTime(raceid);
- Race_SetPositionPrize(raceid,position,prize);
- Race_GetPositionPrize(raceid,position);
- A serem feitas:
- Race_SetStartTime(raceid,time);
- Race_Start(raceid);
- Race_PlayerJoin(playerid,raceid);
- Race_PlayerLeave(playerid);
- Race_GetPlayerDistanceFromPutted(playerid,putted,type);
- Race_GetPlayerTime(playerid);
- Race_GetPlayerPosition(playerid);
- GetPlayerRace(playerid);
- \*----------------------------------------------------------------------------*/
- #define MAX_POSITIONS_R (5)
- #define MAX_SPAWNS (25)
- #define MAX_CHECKS (100)
- const sizeof_rSpawn = MAX_SPAWNS * 4;
- const sizeof_rCheck = MAX_CHECKS * 3;
- enum _RaceInfo
- {
- Float:rSpawn[sizeof_rSpawn],
- Float:rCheck[sizeof_rCheck],
- rInterior,
- rVirtualWorld,
- rName[30],
- bool:rCreated,
- rNumSpawn,
- rNumChecks,
- rLaps,
- bool:rActive,
- rMaxTime,
- rPositionPrize[MAX_POSITIONS_R],
- }
- #define rSpawn][%1][%2] rSpawn][((%1) * 4)+(%2)]
- #define rCheck][%1][%2] rCheck][((%1) * 3)+(%2)]
- new Race[MAX_RACES][_RaceInfo];
- stock Race_Stop(raceid,bool:restart = false)
- {
- if(!Race_Exists(raceid))
- {
- FormatLog(""LogFile"/Erros.log","Não foi possível parar a corrida %d. Ela não existe",raceid);
- return false;
- }
- if(Race_IsActive(raceid))
- {
- FormatLog(""LogFile"/Erros.log","Não foi possível parar a corrida %d. Ela não está iniciada.",raceid);
- return false;
- }
- if(restart)
- {
- KillTimer(Race[id][rTimer]);
- }
- foreach(Player,i)
- {
- if(GetPlayerRace(i) == raceid)
- {
- Race_PlayerLeave(i);
- }
- }
- return true;
- }
- stock Race_Create(name[],laps = 1,int = 0,vw = 0,maxtime = -1);
- {
- new id = -1;
- Loop:i(0,MAX_RACES)
- {3
- if(!Race[i][rCreated])
- {
- id = i;
- break;
- }
- }
- if(id == -1)
- {
- FormatLog(""LogFile"/Erros.log","Não foi possível criar a corrida %s, o limite de corridas foi atingido.",name);
- return id;
- }
- Loop:i(0,_RaceInfo)
- {
- Race[id][_RaceInfo:i] = 0;
- }
- Race[id][rCreated] = true;
- strcat(Race[id][rName],name);
- Race_SetInterior(id,int);
- Race_SetVirtualWorld(id,vw);
- Race_SetMaxTime(id,maxtime);
- Race_SetLaps(id,laps);
- return id;
- }
- stock Race_Destroy(raceid)
- {
- if(!Race_Exists(raceid))
- {
- FormatLog(""LogFile"/Erros.log","Não foi possível remover a corrida %d. Ela não existe",raceid);
- return false;
- }
- if(Race_IsActive(raceid))
- {
- Race_Stop(raceid,true);
- }
- Loop:i(0,_RaceInfo)
- {
- Race[raceid][_RaceInfo:i] = 0;
- }
- return true;
- }
- stock Race_Exists(raceid)
- {
- return Race[raceid][rCreated];
- }
- stock Race_IsActive(raceid)
- {
- return Race[raceid][rActive];
- }
- stock Race_AddCheckPoint(raceid,Float:x,Float:y,Float:z)
- {
- if(!Race_Exists(raceid))
- {
- FormatLog(""LogFile"/Erros.log","Não foi possível adicionar o CheckPoint (%03f,%03f,%03f) na corrida id (%d). Ela não existe",x,y,z,raceid);
- return false;
- }
- if(Race_GetNumCheckPoints(raceid) >= MAX_CHECKS)
- {
- FormatLog(""LogFile"/Erros.log","Não foi possível adicionar o checkpoint (%03f,%03f,%03f) na corrida id (%d). O limite foi atingido.",x,y,z,raceid);
- return false;
- }
- new id = Race_GetNumCheckPoints(raceid);
- Race[raceid][rCheck][id][0] = x;
- Race[raceid][rCheck][id][1] = y;
- Race[raceid][rCheck][id][2] = z;
- Race[raceid][rNumChecks] ++;
- return true;
- }
- stock Race_AddSpawn(raceid,Float:x,Float:y,Float:z,Float:ang)
- {
- if(!Race_Exists(raceid))
- {
- FormatLog(""LogFile"/Erros.log","Não foi possível adicionar o spawn (%03f,%03f,%03f,%03f) na corrida id (%d). Ela não existe",x,y,z,ang,raceid);
- return false;
- }
- if(Race_GetNumSpawns(raceid) >= MAX_SPAWNS)
- {
- FormatLog(""LogFile"/Erros.log","Não foi possível adicionar o spawn (%03f,%03f,%03f,%03f) na corrida id (%d). O limite foi atingido.",x,y,z,ang,raceid);
- return false;
- }
- new id = Race_GetNumSpawns(raceid);
- Race[raceid][rSpawn][id][0] = x;
- Race[raceid][rSpawn][id][1] = y;
- Race[raceid][rSpawn][id][2] = z;
- Race[raceid][rNumSpawn] ++;
- return true;
- }
- stock Race_GetNumSpawns(raceid)
- {
- if(!Race_Exists(raceid))
- {
- FormatLog(""LogFile"/Erros.log","Não foi possível obeter o Numero de Spawns da corrida %d. Ela não existe",raceid);
- return false;
- }
- return Race[raceid][rNumSpawn];
- }
- stock Race_GetNumCheckPoints(raceid)
- {
- if(!Race_Exists(raceid))
- {
- FormatLog(""LogFile"/Erros.log","Não foi possível obeter o Numero de CheckPoints da corrida %d. Ela não existe",raceid);
- return false;
- }
- return Race[raceid][rNumCheck];
- }
- stock Race_SetWorld(raceid,world)
- {
- if(!Race_Exists(raceid))
- {
- FormatLog(""LogFile"/Erros.log","Não foi possível setar o Virtual World da corrida %d. Ela não existe",raceid);
- return false;
- }
- Race[raceid][rVirtualWorld] = world;
- if(Race_IsActive(raceid))
- {
- foreach(Player,i)
- {
- if(GetPlayerRace(i) == raceid)
- {
- SetPlayerVirtualWorld(i,world);
- }
- }
- }
- }
- stock Race_SetInterior(raceid,int)
- {
- if(!Race_Exists(raceid))
- {
- FormatLog(""LogFile"/Erros.log","Não foi possível setar o interior da corrida %d. Ela não existe",raceid);
- return false;
- }
- Race[raceid][rInterior] = int;
- if(Race_IsActive(raceid))
- {
- foreach(Player,i)
- {
- if(GetPlayerRace(i) == raceid)
- {
- SetPlayerInterior(i,int);
- }
- }
- }
- }
- stock Race_GetVirtualWorld(raceid)
- {
- if(!Race_Exists(raceid))
- {
- FormatLog(""LogFile"/Erros.log","Não foi possível obeter o Virtual World da corrida %d. Ela não existe",raceid);
- return false;
- }
- return Race[raceid][rVirtualWorld];
- }
- stock Race_GetInterior(raceid)
- {
- if(!Race_Exists(raceid))
- {
- FormatLog(""LogFile"/Erros.log","Não foi possível obeter o interior da corrida %d. Ela não existe",raceid);
- return false;
- }
- return Race[raceid][rInterior];
- }
- stock Race_SetLaps(raceid,laps)
- {
- if(!Race_Exists(raceid))
- {
- FormatLog(""LogFile"/Erros.log","Não foi possível Setar voltas a corrida %d. Ela não existe",raceid);
- return false;
- }
- Race[raceid][rLaps] = laps;
- }
- stock Race_SetMaxTime(raceid,maxtime)
- {
- if(!Race_Exists(raceid))
- {
- FormatLog(""LogFile"/Erros.log","Não foi possível setar o tempo maximo da corrida %d. Ela não existe",raceid);
- return false;
- }
- Race[raceid][rMaxTime] = maxtime;
- }
- stock Race_GetMaxTime(raceid)
- {
- if(!Race_Exists(raceid))
- {
- FormatLog(""LogFile"/Erros.log","Não foi possível obeter o tempo maximo da corrida %d. Ela não existe",raceid);
- return false;
- }
- return Race[raceid][rMaxTime];
- }
- stock Race_GetPositionPrize(raceid,position)
- {
- if(!Race_Exists(raceid))
- {
- FormatLog(""LogFile"/Erros.log","Não foi possível obeter o premio da posicao %d, da corrida %d. Ela não existe",position,raceid);
- return -1;
- }
- return Race[raceid][rPositionPrize][position];
- }
- stock Race_SetPositionPrize(raceid,position,prize)
- {
- if(!Race_Exists(raceid))
- {
- FormatLog(""LogFile"/Erros.log","Não foi possível obeter o premio da posicao %d, da corrida %d. Ela não existe",position,raceid);
- return false;
- }
- Race[raceid][rPositionPrize][position] = prize;
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement