/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>
#include <engine>
#include <amxmisc>
#include <fun>
#include <playermodel>
#define PLUGIN "CS Rally"
#define VERSION "3.0"
#define AUTHOR "mabaclu"
#define CHECKPOINT_DISTANCE 200.0
#define MAX_CHECKPOINTS 30
#define CARMENU_OFFSET 123401
#define FREEZETIME_OFFSET 2712
#define TURBO_OFFSET 1039
#pragma dynamic 7000
new const oldknife_sounds[][] =
{
"weapons/knife_deploy1.wav", // Deploy Sound
"weapons/knife_hit1.wav", // Hit 1
"weapons/knife_hit2.wav", // Hit 2
"weapons/knife_hit3.wav", // Hit 3
"weapons/knife_hit4.wav", // Hit 4
"weapons/knife_hitwall1.wav", // Hit Wall
"weapons/knife_slash1.wav", // Slash 1
"weapons/knife_slash2.wav", // Slash 2
"weapons/knife_stab.wav",
"common/wpn_select.wav"
}
new g_CheckpointID_to_Ent[MAX_CHECKPOINTS] = 0;
new g_MaxPlayers
new bool:g_lado[33];
new g_DriveAngle[33];
new Float:maxs[2][3] = {{-4800.0,-4800.0,-4800.0},{-4800.0,-4800.0,-4800.0}}
new Float:mins[2][3] = {{4800.0,4800.0,4800.0},{4800.0,4800.0,4800.0}}
new g_CheckpointID[33] = 0;
new g_Lap[33]
new g_TotalLaps
new Float:g_LastTime[33]
new Float:g_flRaceTime
new Float:g_flRaceStarted
new bool:g_HasTurbo[33]
new bool:g_TurboActivated[33]
enum _:PositionsData {
ID,
Position,
Float: LastTime
}
new Fsize = 0;
//new exploSpr
new CheckpointSprite[100]
new FinalCheckpointSprite[100]
new g_ModelInterior[100]
new g_SoundEngine[100]
new g_DustSprite
new bool:g_ILoveProPortugueseGaming = true
new g_OldOrigin[33][3];
new iaPosition[33][3];
new bool:g_ThirdPerson[33];
new g_Car[33]
new g_TemporaryCar[33];
new bool:g_EngineSound[33];
new bool:g_FreezeTime = true
new g_HideWeapon
/*
----------------------------------------------------------------------------------------------------
Plugin created by mabaclu
and sold to KfarSavTa
----------------------------------------------------------------------------------------------------
*/
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
g_TotalLaps = register_cvar("amx_csrally_laps","8")
RegisterHam(Ham_Spawn,"player","PlayerPostSpawn",1);
set_task(1.1, "speed_task", 444990, "", 0, "b");
//set_task(25.5, "sprites_task", 2697801, "", 0, "b")
set_task(1.3, "engine_task", 39418, "", 0, "b")
set_task(1.0, "GetPositions", 77662, "", 0, "b")
set_task(0.1, "dust_task", 21492, "", 0, "b")
set_task(121.0, "advertise", 1432423, "", 0, "b")
g_MaxPlayers = get_maxplayers();
register_forward(FM_CmdStart, "CmdStart");
register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
register_forward(FM_PlayerPostThink, "fw_PlayerPostThink")
register_forward(FM_Think,"FM_Think_Hook")
register_forward(FM_EmitSound, "fw_EmitSound")
register_logevent("eRoundEnd", 2, "1=Round_End")
register_logevent("RaceStart", 2, "1=Round_Start")
register_event("HLTV", "event_new_round", "a", "1=0", "2=0")
g_HideWeapon = get_user_msgid("HideWeapon");
register_event("ResetHUD", "eReset", "b")
//register_clcmd("say /start", "RaceStart")
RegisterHam(Ham_Player_Jump, "player", "Player_Jump")
register_dictionary("csrally.txt")
register_message( get_user_msgid( "StatusIcon" ), "Msg_StatusIcon" );
register_message(g_HideWeapon, "msgHideWeapon")
//register_clcmd("say /cam", "cmdCam")
register_clcmd("say /kocsi", "CarMenu")
register_clcmd("say /kocsik", "CarMenu")
register_clcmd("say /inditas", "Engine_ON")
register_clcmd("say /lealitas", "Engine_OFF")
register_concmd("amx_csrally_set_checkpoint","newcheckpoint",ADMIN_BAN,"Sets your current location to the new T checkpoint Spawn Location.")
new configfile[200]
get_configsdir(configfile,199)
new mapname[32]
server_print(configfile)
get_mapname(mapname,31)
server_print(mapname)
format(configfile,199,"%s/CSRally_checkpoints/%s.ini",configfile, mapname)
if(file_exists(configfile))
{
Fsize = file_size(configfile) - 1
}
server_print(configfile)
make_checkpoints()
register_event("CurWeapon", "Event_CurWeapon", "be","1=1")
register_forward(FM_SetModel, "fw_SetModel")
for (new i; i<sizeof(g_EngineSound); i++)
{
g_EngineSound[i] = true;
}
}
public plugin_precache()
{
precache_model("models/rpgrocket.mdl")
CheckpointSprite = "sprites/ppg_checkpoint6.spr";
FinalCheckpointSprite = "sprites/ppg_finalcheckpoint.spr"
precache_model(CheckpointSprite);
precache_model(FinalCheckpointSprite)
g_ModelInterior = "models/interior.mdl";
precache_model(g_ModelInterior)
precache_sound("voc/checkpoint.wav")
g_SoundEngine = "engine/z28_engine.wav"
precache_sound(g_SoundEngine)
g_DustSprite = precache_model("sprites/lightsmoke.spr")
precache_model("models/player/206/206.mdl")
precache_model("models/player/accent/accent.mdl")
precache_model("models/player/locust/locust.mdl")
precache_sound( "fvox/ten.wav" ) ;
precache_sound( "fvox/nine.wav" ) ;
precache_sound( "fvox/eight.wav" ) ;
precache_sound( "fvox/seven.wav" ) ;
precache_sound( "fvox/six.wav" ) ;
precache_sound( "fvox/five.wav" ) ;
precache_sound( "fvox/four.wav" ) ;
precache_sound( "fvox/three.wav" ) ;
precache_sound( "fvox/two.wav" ) ;
precache_sound( "fvox/one.wav" ) ;
}
public eReset(id)
{
new iFlags
iFlags |= (1<<0)
iFlags |= (1<<4)
iFlags |= (1<<5)
iFlags |= (1<<6)
message_begin( MSG_ONE, g_HideWeapon, _, id );
write_byte(iFlags);
message_end();
}
public msgHideWeapon()
{
new iFlags
iFlags |= (1<<0)
iFlags |= (1<<4)
iFlags |= (1<<5)
iFlags |= (1<<6)
set_msg_arg_int(1, ARG_BYTE, get_msg_arg_int(1) | iFlags)
}
public fw_EmitSound(id, channel, const sound[])
{
if(!is_user_alive(id))
return FMRES_IGNORED
// Check sound
for(new i = 0; i < sizeof oldknife_sounds; i++)
{
if(equal(sound, oldknife_sounds[i]))
{
return FMRES_SUPERCEDE
}
}
return FMRES_IGNORED
}
public Msg_StatusIcon( msgid, msgdest, id ) {
static szMsg[ 8 ];
get_msg_arg_string( 2, szMsg, 7 );
if( equal( szMsg, "buyzone" ) && get_msg_arg_int( 1 ) ) {
set_pdata_int( id, 235, get_pdata_int( id, 235 ) & ~( 1 << 0 ) );
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public event_new_round()
{
new FreezeTime = get_cvar_num("mp_freezetime")
g_FreezeTime = true;
Countdown(FreezeTime + FREEZETIME_OFFSET)
}
public Countdown(FreezeTime)
{
FreezeTime -= FREEZETIME_OFFSET
new szFreezeTimeWord[10]
num_to_word(FreezeTime, szFreezeTimeWord, charsmax(szFreezeTimeWord))
if(1 <= FreezeTime <= 10)
{
client_cmd(0, "spk sound/fvox/%s.wav", szFreezeTimeWord)
}
FreezeTime--
if(FreezeTime > 0)
{
set_task(1.0, "Countdown", FreezeTime + FREEZETIME_OFFSET)
}
}
public RaceStart()
{
g_FreezeTime = false
for (new id;id<=g_MaxPlayers;id++)
{
switch(g_Car[id])
{
case 1:
{
fm_set_user_model(id, "206");
}
case 2:
{
fm_set_user_model(id, "accent");
}
case 3:
{
fm_set_user_model(id, "locust");
}
}
set_task(9.0, "Turbo_On", id + TURBO_OFFSET)
}
speed_task();
g_flRaceStarted = get_gametime();
set_task(0.1, "StartTimer", .flags="b")
}
public Turbo_On(id)
{
id -= TURBO_OFFSET
g_HasTurbo[id] = true;
}
public Turbo_Off(id)
{
id -= TURBO_OFFSET
g_HasTurbo[id] = false;
g_TurboActivated[id] = false;
set_task(25.0, "Turbo_On", id + TURBO_OFFSET)
}
public Turbo(id)
{
if (g_HasTurbo[id])
{
g_TurboActivated[id] = true
speed_task()
set_task(4.0, "Turbo_Off", id + TURBO_OFFSET)
set_task(4.0, "speed_task")
}
}
public Event_CurWeapon(id)
{
set_pev(id, pev_viewmodel, engfunc(EngFunc_AllocString, g_ModelInterior))
set_pev(id ,pev_weaponmodel2,"")
}
public fw_SetModel(const iEntity, const szModel[])
{
if(pev_valid(iEntity))
{
set_pev(iEntity, pev_viewmodel, engfunc(EngFunc_AllocString, g_ModelInterior))
set_pev(iEntity ,pev_weaponmodel2,"")
}
}
public client_disconnect(id)
{
g_Car[id] = 0;
g_TemporaryCar[id] = 0;
}
public PlayerPostSpawn(id)
{
g_Car[id] = g_TemporaryCar[id];
switch(g_Car[id])
{
case 1:
{
if(!g_FreezeTime){
set_pev(id, pev_maxspeed, 500.0)
set_pev(id, pev_friction, 0.15)
}
}
case 2:
{
if(!g_FreezeTime){
set_pev(id, pev_maxspeed, 450.0)
set_pev(id, pev_friction, 0.3)
}
}
case 3:
{
if(!g_FreezeTime){
set_pev(id, pev_maxspeed, 400.0)
set_pev(id, pev_friction, 0.6)
}
}
default:
{
if(!g_FreezeTime){
set_pev(id, pev_maxspeed, 450.0)
set_pev(id, pev_friction, 0.3)
}
if(g_Car[id] == 0)
{
if(is_user_connected(id))
fm_set_user_model(id, "accent");
}
}
}
client_cmd(id, "cl_forwardspeed 1000.0")
if(is_user_alive(id)){
strip_user_weapons(id)
give_item(id, "weapon_knife")
set_user_godmode(id, 1)
}
}
public speed_task()
{
if(!g_FreezeTime){
for (new id = 1; id <= g_MaxPlayers; id++)
{
if(!is_user_connected(id)) continue
switch(g_Car[id])
{
case 1:
{
if(g_TurboActivated[id])
{
set_pev(id, pev_maxspeed, 600.0)
}
else
{
set_pev(id, pev_maxspeed, 500.0)
}
set_pev(id, pev_friction, 0.15)
}
case 2:
{
if(g_TurboActivated[id])
{
set_pev(id, pev_maxspeed, 550.0)
}
else
{
set_pev(id, pev_maxspeed, 450.0)
}
set_pev(id, pev_friction, 0.3)
}
case 3:
{
if(g_TurboActivated[id])
{
set_pev(id, pev_maxspeed, 500.0)
}
else
{
set_pev(id, pev_maxspeed, 400.0)
}
set_pev(id, pev_friction, 0.6)
}
default:
{
if(g_TurboActivated[id])
{
set_pev(id, pev_maxspeed, 550.0)
}
else
{
set_pev(id, pev_maxspeed, 450.0)
}
set_pev(id, pev_friction, 0.3)
if(g_TemporaryCar[id] == 0)
CarMenu(id)
}
}
}
}
set_hudmessage(255, 212, 42, 0.21, 0.91, 0, 6.0, 20.0)
show_hudmessage(0, "%L", LANG_PLAYER, "SPEED")
}
public CarMenu(id)
{
if (id>33)
{
id-=CARMENU_OFFSET
}
//first we need to make a variable that will hold the menu
new szMenuName[50]
format(szMenuName, charsmax(szMenuName), "%L", id, "MENU_NAME")
new menu = menu_create(szMenuName, "menu_handler");
//Note - menu_create
//The first parameter is what the menu will be titled (what is at the very top)
//The second parameter is the function that will deal/handle with the menu (which key was pressed, and what to do)
new szCar1[100]
new szCar2[100]
new szCar3[100]
formatex(szCar1, charsmax(szCar1), "%L", id, "CAR1")
formatex(szCar2, charsmax(szCar2), "%L", id, "CAR2")
formatex(szCar3, charsmax(szCar3), "%L", id, "CAR3")
//Now lets add some things to select from the menu
menu_additem(menu, szCar1, "1", 0);
menu_additem(menu, szCar2, "2", 0);
menu_additem(menu, szCar3, "3", 0);
//Note - menu_additem
//The first parameter is which menu we will be adding this item/selection to
//The second parameter is what text will appear on the menu (Note that it is preceeded with a number of which item it is)
//The third parameter is data that we want to send with this item
//The fourth parameter is which admin flag we want to be able to access this item (I have had no experience with this, so I am just assuming this is how it works. It uses the admin flags from the amxconst.inc)
//Set a property on the menu
menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
//Note - menu_setprop
//The first parameter is the menu to modify
//The second parameter is what to modify (found in amxconst.inc)
//The third parameter is what to modify it to (in this case, we are adding a option to the menu that will exit the menu. setting it to MEXIT_NEVER will disable this option)
//Lets display the menu
menu_display(id, menu, 0);
//Note - menu_display
//The first parameter is which index to show it to (you cannot show this to everyone at once)
//The second parameter is which menu to show them (in this case, the one we just made)
//The third parameter is which page to start them on
}
//okay, we showed them the menu, now lets handle it (looking back at menu_create, we are going to use that function)
public menu_handler(id, menu, item)
{
//we don't want to deal with them if they exited a menu
if( item == MENU_EXIT )
{
menu_destroy(menu);
//Note that you will want to destroy the menu after they do something
return PLUGIN_HANDLED;
}
//now lets create some variables that will give us information about the menu and the item that was pressed/chosen
new data[6], szName[64];
new access, callback;
//heres the function that will give us that information (since it doesnt magicaly appear)
menu_item_getinfo(menu, item, access, data,charsmax(data), szName,charsmax(szName), callback);
//Note - that you can do this next step how you want, this is just the way I prefer
//looking back to menu_additem, we sent data with every item we added, this is where it gets a little fishy for us (where you can do your own method)
new key = str_to_num(data);
//note that all my datas were numbers (you can do it with whatever type of string you want)
//now lets find which item was pressed
switch(key)
{
case 1:
{
client_print(id, print_chat, "%L", id, "CAR1_CHOSEN");
//note that if we dont want to continue through the function, we can't just end with a return. We want to kill the menu first
//menu_destroy(menu);
//return PLUGIN_HANDLED;
//fm_set_user_model(id, "206");
}
case 2:
{
client_print(id, print_chat, "%L", id, "CAR2_CHOSEN");
//fm_set_user_model(id, "accent");
}
case 3: //again i don't have experience with the admin limitations, so i don't know if you need to have a check before this (im assuming you don't though ^_^)
{
client_print(id, print_chat, "%L", id, "CAR3_CHOSEN");
//fm_set_user_model(id, "locust");
}
}
//g_Car[id]=key;
g_TemporaryCar[id]=key;
//lets finish up this function with a menu_destroy, and a return
menu_destroy(menu);
return PLUGIN_HANDLED;
}
public StartTimer()
{
g_flRaceTime = get_gametime() - g_flRaceStarted
new iRaceTime = floatround(g_flRaceTime, floatround_floor)
new iMiliSec = floatround((g_flRaceTime*10.0) - (iRaceTime*10), floatround_floor)
new iMinutes = floatround(iRaceTime/60.0, floatround_floor)
new iSeconds = iRaceTime - iMinutes*60
client_print(0, print_center, "%i:%i.%i", iMinutes, iSeconds, iMiliSec)
}
public CmdStart(Client, Handle)
{
new button = pev(Client,pev_button);
if((button & IN_MOVELEFT) && !(button & IN_MOVERIGHT))
{
client_cmd(Client, "cl_sidespeed 0");
g_lado[Client] = true;
g_DriveAngle[Client] += 1.0
}
else if(!(button & IN_MOVELEFT) && (button & IN_MOVERIGHT))
{
client_cmd(Client, "cl_sidespeed 0");
g_lado[Client] = true;
g_DriveAngle[Client] -= 1.0
}
else
{
g_lado[Client] = false;
}
if(button & IN_USE)
{
Turbo(Client)
}
}
public fw_PlayerPostThink(id)
{
if(!g_lado[id])
{
client_cmd(id, "cl_sidespeed 400.0");
}
}
public fw_PlayerPreThink(id)
{
static target
static Float:velocity[3]
static Float:speedh
for (new id; id<=g_MaxPlayers; id++)
{
if(!is_user_alive(id)) continue
target = pev(id, pev_iuser1) == 4 ? pev(id, pev_iuser2) : id
pev(target, pev_velocity, velocity)
speedh = floatsqroot(floatpower(velocity[0], 2.0) + floatpower(velocity[1], 2.0))
set_user_armor(id,floatround(speedh, floatround_round))
}
}
public Player_Jump(id)
{
static iOldbuttons ; iOldbuttons = entity_get_int(id, EV_INT_oldbuttons)
if( !(iOldbuttons & IN_JUMP) )
{
entity_set_int(id, EV_INT_oldbuttons, iOldbuttons | IN_JUMP)
return HAM_HANDLED
}
return HAM_IGNORED
}
public newcheckpoint(id,team)
{
new configfile[200]
get_configsdir(configfile,199)
new mapname[32]
get_mapname(mapname,31)
format(configfile,199,"%s/CSRally_checkpoints/%s.ini",configfile, mapname)
Fsize = file_size(configfile) - 1
new string[200]
new Float:origin[3]
new Float:v_angle[3]
pev(id,pev_origin,origin)
pev(id,pev_v_angle,v_angle)
if(file_exists(configfile))
{
Fsize = file_size(configfile,1) - 1
format(string,199,"%s | %f %f %f %f %f %f",mapname,origin[0],origin[1],origin[2], v_angle[0], v_angle[1], v_angle[2])
write_file(configfile,string,-1)
}
else
{
format(string,199,"%s | %f %f %f %f %f %f",mapname,origin[0],origin[1],origin[2], v_angle[0], v_angle[1], v_angle[2])
write_file(configfile,string,-1)
}
}
public advertise()
{
client_print(0, print_chat, "CS Rally %s by mabaclu", VERSION);
}
public get_checkpoint_origins(checkpointid, Float:origin[3], Float:v_angle[3])
{
new i
new Float:midpoint[2][3]
for(i=0;i<2;i++)
{
for(new j=0;j<3;j++)
{
midpoint[i][j] = (maxs[i][j] + mins[i][j]) / 2.0
}
}
new configfile[200]
get_configsdir(configfile,199)
new mapname[32]
get_mapname(mapname,31)
format(configfile,199,"%s/CSRally_checkpoints/%s.ini",configfile, mapname)
origin[0] = midpoint[0][0]
origin[1] = midpoint[0][1]
origin[2] = midpoint[0][2]
new string[200]
format(string,199,"%s | ",mapname)
if(file_exists(configfile))
{
new read[200], trash
Fsize = file_size(configfile,1) - 1
if (checkpointid <= Fsize)
{
read_file(configfile,(checkpointid - 1),read,199,trash)
if(containi(read,string)==0)
{
format(read,199,read[strlen(string)])
replace_all(read,199," | ","")
strbreak(read,string,199,read,199)
origin[0] = str_to_float(string)
strbreak(read,string,199,read,199)
origin[1] = str_to_float(string)
strbreak(read,string,199,read,199)
origin[2] = str_to_float(string)
strbreak(read,string,199,read,199)
v_angle[0] = str_to_float(string)
strbreak(read,string,199,read,199)
v_angle[1] = str_to_float(string)
strbreak(read,string,199,read,199)
v_angle[2] = str_to_float(string)
}
}
}
return ;
}
public FM_Think_Hook(ent)
{
if(pev_valid(ent))
{
static classname[32]
pev(ent,pev_classname,classname,31)
if(equal(classname,"CSRally_Checkpoint"))
{
Checkpoint_Think_Hook(ent)
set_pev(ent,pev_nextthink,0.1)
}
}
}
/*
Checkpoint Think
*/
public Checkpoint_Think_Hook(ent)
{
new Float:origin[3]
new Float:checkpoint_origin[3]
new Float:v_angle[3]
new checkpointid
for (new c = 1; c < MAX_CHECKPOINTS; c++)
{
if (g_CheckpointID_to_Ent[c] == ent)
{
checkpointid = c
break;
}
}
static players[32], num
get_players(players,num,"ach")
for(new i=0;i<num;i++)
{
pev(players[i], pev_origin, origin)
get_checkpoint_origins(checkpointid, checkpoint_origin, v_angle)
if(get_distance_f(origin,checkpoint_origin)<CHECKPOINT_DISTANCE)
{
if (g_CheckpointID[players[i]] == (checkpointid - 1))
{
g_CheckpointID[players[i]]++;
client_cmd(players[i],"spk voc/checkpoint.wav")
g_LastTime[players[i]] = g_flRaceTime;
//client_print(players[i], print_chat, "You have completed %i out of %i checkpoints in this lap.", g_CheckpointID[players[i]], Fsize)
if (g_CheckpointID[players[i]] >= Fsize)
{
g_Lap[players[i]]++;
g_CheckpointID[players[i]] = 0;
if (g_Lap[players[i]] >= get_pcvar_num(g_TotalLaps))
{
g_Lap[players[i]] = 0;
new name[64]
get_user_name(players[i], name, sizeof(name))
client_print(0, print_chat, "%L", LANG_PLAYER, "RACE_WINNER", name)
eRoundEnd()
set_task(2.0, "kill_winner")
for (new k; k<num; k++)
{
if (k != i)
{
user_silentkill(players[k])
}
}
}
//else
//{
//client_print(players[i], print_chat, "You have completed %i out of %i laps.", g_Lap[players[i]], get_pcvar_num(g_TotalLaps))
//}
}
}
}
}
return ;
}
public kill_winner()
{
for (new i; i<=g_MaxPlayers; i++)
{
if (is_user_alive(i))
{
user_silentkill(i)
}
}
}
public make_checkpoints()
{
for (new k = 1; k <= Fsize; k++)
{
new Float:checkpoint_origin[3]
new Float:v_angle[3]
new ent = engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"info_target"))
g_CheckpointID_to_Ent[k] = ent;
set_pev(ent,pev_classname,"CSRally_Checkpoint")
//engfunc(EngFunc_SetModel,ent,red_flag_model)
set_pev(ent,pev_movetype,MOVETYPE_FLY)
FM_Think_Hook(ent)
get_checkpoint_origins(k, checkpoint_origin, v_angle)
engfunc(EngFunc_SetOrigin,ent,checkpoint_origin)
if (k == Fsize)
{
checkpoint_final_sprite(checkpoint_origin, v_angle)
}
else
{
checkpoint_sprite(checkpoint_origin, v_angle)
}
}
}
public GetPositions()
{
new _:iaPosition[33][PositionsData];
new iPlayers[32], bool:idChecked[33], iNum, iPosition
get_players(iPlayers, iNum);
for(new i; i<=iNum; i++)
{
new id = iPlayers[i]
if(is_user_connected(id) && !idChecked[id])
{
iPosition = (Fsize*g_Lap[id])+g_CheckpointID[id]
iaPosition[id][ID] = id
iaPosition[id][Position] = iPosition
iaPosition[id][LastTime] = _:g_LastTime[id]
}
}
SortCustom2D(iaPosition, 33, "fn_StatsCompare")
new szPositions[30]
formatex (szPositions, charsmax(szPositions), "%L", LANG_PLAYER, "POSITIONS")
new szTable[2000]
formatex(szTable, charsmax(szTable), "^n^n%s:^n", szPositions)
for(new i; i<=32; i++)
{
new id = iaPosition[i][ID]
if(is_user_connected(id) && (g_Lap[id] != 0 || g_CheckpointID[id] != 0))
{
new szName[100]
get_user_name(id, szName, charsmax(szName))
format(szName, charsmax(szName), "#%i - %s^n", i+1, szName)
add(szTable, charsmax(szTable), szName)
}
}
new szCheckPoint[32] = "Checkpoint: "
new szSlash[5] = "/"
new szMLLap[20]
formatex(szMLLap, charsmax(szMLLap), "%L", LANG_PLAYER, "LAP")
new szLap[24]
formatex(szLap, charsmax(szLap), "^n%s: ", szMLLap)
new szCheckpointID[5]
new szFsize[5]
new szLapID[5]
new szG_TotalLaps[5]
new szHudMessage[2100]
for(new i;i<=g_MaxPlayers; i++)
{
szHudMessage = "";
if(is_user_alive(i))
{
add(szHudMessage, charsmax(szHudMessage), szCheckPoint)
num_to_str(g_CheckpointID[i], szCheckpointID, sizeof(szCheckpointID))
add(szHudMessage, charsmax(szHudMessage), szCheckpointID)
add(szHudMessage, charsmax(szHudMessage), szSlash)
num_to_str(Fsize, szFsize, sizeof(szFsize))
add(szHudMessage, charsmax(szHudMessage), szFsize)
add(szHudMessage, charsmax(szHudMessage), szLap)
num_to_str(g_Lap[i] + 1, szLapID, sizeof(szCheckpointID))
add(szHudMessage, charsmax(szHudMessage), szLapID)
add(szHudMessage, charsmax(szHudMessage), szSlash)
num_to_str(get_pcvar_num(g_TotalLaps), szG_TotalLaps, sizeof(szFsize))
add(szHudMessage, charsmax(szHudMessage), szG_TotalLaps)
}
add(szHudMessage, charsmax(szHudMessage), szTable)
set_hudmessage(0, 50, 255, 0.03, 0.22, _, _, 20.0, _, _, 3)
show_hudmessage(i, "%s", szHudMessage)
}
}
public fn_StatsCompare(elem1[], elem2[])
{
if(elem1[Position] > elem2[Position])
{
return -1;
}
else if(elem1[Position] == elem2[Position])
{
if(g_LastTime[elem1[ID]] < g_LastTime[elem2[ID]])
{
return -1;
}
else if(g_LastTime[elem1[ID]] > g_LastTime[elem2[ID]])
{
return 1;
}
return 0;
}
return 1;
}
public dust_task()
{
for (new id = 1; id <= g_MaxPlayers; id++)
{
new origin[3]
if(is_user_alive(id))
{
get_user_origin(id, origin)
if(!(origin[0] == g_OldOrigin[id][0] && origin[1] == g_OldOrigin[id][1] && origin[2] ==g_OldOrigin[id][2]))
{
message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_GLOWSPRITE)
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2])
write_short(g_DustSprite)
write_byte(2)
write_byte(20)
write_byte(150)
message_end()
}
g_OldOrigin[id] = origin;
}
}
}
public cmdCam(id)
{
if(g_ThirdPerson[id])
{
set_view(id, CAMERA_NONE)
g_ThirdPerson[id] = false
}
else
{
set_view(id, CAMERA_3RDPERSON)
g_ThirdPerson[id] = true
}
}
public checkpoint_sprite(Float:fOrigin[3], Float:v_angle[3])
{
/*new origin[3]
origin[0] = floatround(fOrigin[0])
origin[1] = floatround(fOrigin[1])
origin[2] = floatround(fOrigin[2]+20)*/
fOrigin[2] += 20;
new ent = create_entity("info_target")
entity_set_string(ent,EV_SZ_classname,"ghw_spawned_ent2")
entity_set_model(ent,CheckpointSprite)
entity_set_origin(ent,fOrigin)
entity_set_vector(ent,EV_VEC_v_angle,v_angle)
entity_set_vector(ent,EV_VEC_angles,v_angle)
entity_set_int(ent, EV_INT_solid,SOLID_NOT)
entity_set_int(ent,EV_INT_movetype,MOVETYPE_FLY)
entity_set_edict(ent,EV_ENT_owner,33)
entity_set_float(ent,EV_FL_framerate,1.0)
entity_set_int(ent,EV_INT_sequence,0)
entity_set_size(ent,Float:{-0.1, -0.1, -0.1},Float:{0.1, 0.1, 0.1})
//entity_set_int(ent,EV_INT_renderfx,kRenderFxNone);
//entity_set_vector(ent,EV_VEC_rendercolor,{100,100,100});
//entity_set_int(ent,EV_INT_rendermode,kRenderTransTexture);
//set_pev(ent,pev_rendermode,kRenderTransAdd);
//entity_set_float(ent,EV_FL_renderamt,0.0);
set_rendering(ent, kRenderFxNone, 0, 0, 0, kRenderTransAdd, 255)
/*message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
write_byte(TE_GLOWSPRITE)
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2])
write_short(exploSpr)
write_byte(99999999999999999999)
write_byte(20)
write_byte(150)
message_end()*/
/*message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
write_byte(TE_SPRITE)
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2])
write_short(exploSpr)
write_byte(9999999999999999999)
write_byte(255)
message_end()*/
}
public checkpoint_final_sprite(Float:fOrigin[3], Float:v_angle[3])
{
fOrigin[2] += 20;
new ent = create_entity("info_target")
entity_set_string(ent,EV_SZ_classname,"ghw_spawned_ent3")
entity_set_model(ent,FinalCheckpointSprite)
entity_set_origin(ent,fOrigin)
entity_set_vector(ent,EV_VEC_v_angle,v_angle)
entity_set_vector(ent,EV_VEC_angles,v_angle)
entity_set_int(ent, EV_INT_solid,SOLID_NOT)
entity_set_int(ent,EV_INT_movetype,MOVETYPE_FLY)
entity_set_edict(ent,EV_ENT_owner,33)
entity_set_float(ent,EV_FL_framerate,1.0)
entity_set_int(ent,EV_INT_sequence,0)
entity_set_size(ent,Float:{-0.1, -0.1, -0.1},Float:{0.1, 0.1, 0.1})
set_rendering(ent, kRenderFxNone, 0, 0, 0, kRenderTransAdd, 255)
}
public sprites_task()
{
new Float:origin[3]
new Float:v_angle[3]
for (new checkpointid = 1; checkpointid <= Fsize; checkpointid++)
{
get_checkpoint_origins(checkpointid, origin, v_angle)
checkpoint_sprite(origin, v_angle)
}
}
public engine_task()
{
for (new id = 1; id <= g_MaxPlayers; id++)
{
if(is_user_alive(id) && g_EngineSound[id])
{
client_cmd(id, "spk ^"%s^"", g_SoundEngine)
}
}
}
public Engine_ON(id)
{
g_EngineSound[id] = true;
}
public Engine_OFF(id)
{
g_EngineSound[id] = false;
}
public eRoundEnd()
{
for (new id = 1; id <= g_MaxPlayers; id++)
{
g_CheckpointID[id] = 0
g_Lap[id] = 0
iaPosition[id][0] = 0
iaPosition[id][1] = 0
}
}