Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 97 additions & 47 deletions gameserver/addons/sourcemod/scripting/cpMod/commands.sp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,18 @@ public SaveClientLocation(client)
//if plugin is enabled
if(g_bEnabled)
{
if(Timer_IsPlayerTouchingStartZone(client))
{
PrintToChat(client, "Not allowed inside start zones,");
return;
}

if(Timer_IsPlayerTouchingZoneType(client, ZtAntiCp))
{
PrintToChat(client, "You are insiade an Ati CP zone.");
return;
}

//if player on ground
if(GetEntDataEnt2(client, FindSendPropOffs("CBasePlayer", "m_hGroundEntity")) != -1 || g_bAir)
{
Expand All @@ -94,9 +106,16 @@ public SaveClientLocation(client)
//if player has less than limit checkpoints
if(whole < CPLIMIT)
{
if(!g_bRestore)
{
if(!Timer_GetPauseStatus(client))
Timer_Pause(client);
}
else Timer_Reset(client);

//save some data
GetClientAbsOrigin(client, g_fPlayerCords[client][whole]);
GetClientAbsAngles(client, g_fPlayerAngles[client][whole]);
GetClientEyeAngles(client, g_fPlayerAngles[client][whole]);
GetEntPropVector(client, Prop_Data, "m_vecVelocity", g_fPlayerVelocity[client][whole]);

g_iPlayerLevel[client][whole] = Timer_GetClientLevel(client);
Expand All @@ -115,7 +134,15 @@ public SaveClientLocation(client)
}
}
else if(whole == CPLIMIT)
{ //cp rotation enabled
{
if(!g_bRestore)
{
if(!Timer_GetPauseStatus(client))
Timer_Pause(client);
}
else Timer_Reset(client);

//cp rotation enabled
new current = g_CurrentCp[client];

//if last slot reached
Expand Down Expand Up @@ -204,6 +231,8 @@ public TeleClient(client,pos)
else Client_TelePos(client, pos);
}

new g_iSelectedPos[MAXPLAYERS+1];

public Client_TelePos(client, pos)
{
//if no valid player
Expand All @@ -213,60 +242,81 @@ public Client_TelePos(client, pos)
//if plugin is enabled
if(g_bEnabled)
{
if(g_timer) Timer_Reset(client);

new current = g_CurrentCp[client];
new whole = g_WholeCp[client];

//if on last slot and next
if(current == whole-1 && pos == 1)
if(g_timer)
{
//reset to first
g_CurrentCp[client] = -1;
current = -1;
if(!g_bRestore)
{
if(!Timer_GetPauseStatus(client))
Timer_Pause(client);
}
else Timer_Reset(client);
}
//if on first slot and previous
if(current == 0 && pos == -1)

g_iSelectedPos[client] = pos;
CreateTimer(0.0, Timer_TelePos, client); //Bugfix
}
else //plugin disabled
PrintToChat(client, "%t", "PluginDisabled", YELLOW,LIGHTGREEN,YELLOW);
}

public Action:Timer_TelePos(Handle:timer, any:client)
{
if(!IsClientInGame(client))
return Plugin_Stop;

new current = g_CurrentCp[client];
new whole = g_WholeCp[client];

//if on last slot and next
if(current == whole-1 && g_iSelectedPos[client] == 1)
{
//reset to first
g_CurrentCp[client] = -1;
current = -1;
}
//if on first slot and previous
if(current == 0 && g_iSelectedPos[client] == -1)
{
//reset to last
g_CurrentCp[client] = whole;
current = whole;
}

new actual = current+g_iSelectedPos[client];

//if not valid checkpoint
//if(actual < 0 || actual > whole || (g_fPlayerCords[client][actual][0] == 0.0 && g_fPlayerCords[client][actual][1] == 0.0 && g_fPlayerCords[client][actual][2] == 0.0)){
if(actual < 0 || actual > whole)
{
PrintToChat(client, "%t", "CpNotFound", YELLOW,LIGHTGREEN,YELLOW);
}
else
{
if(g_timerMapzones)
{
//reset to last
g_CurrentCp[client] = whole;
current = whole;
if(Timer_IsPlayerTouchingStartZone(client))
Timer_SetIgnoreEndTouchStart(client, 1);
}

new actual = current+pos;
Timer_RestoreLastJumps(client);

//if not valid checkpoint
//if(actual < 0 || actual > whole || (g_fPlayerCords[client][actual][0] == 0.0 && g_fPlayerCords[client][actual][1] == 0.0 && g_fPlayerCords[client][actual][2] == 0.0)){
if(actual < 0 || actual > whole)
if(g_bVelocity)
TeleportEntity(client, g_fPlayerCords[client][actual], g_fPlayerAngles[client][actual], g_fPlayerVelocity[client][actual]);
else TeleportEntity(client, g_fPlayerCords[client][actual], g_fPlayerAngles[client][actual], Float:{0.0,0.0,-100.0});//stop him
PrintToChat(client, "%t", "CpTeleported", YELLOW,LIGHTGREEN,YELLOW,GREEN,actual+1,whole,YELLOW);
g_CurrentCp[client] += g_iSelectedPos[client];

if(g_bEffects)
{
PrintToChat(client, "%t", "CpNotFound", YELLOW,LIGHTGREEN,YELLOW);
}
else
{
if(g_timerMapzones)
{
if(Timer_IsPlayerTouchingZoneType(client, ZtStart) || Timer_IsPlayerTouchingZoneType(client, ZtBonusStart))
Timer_SetIgnoreEndTouchStart(client, 1);
}

if(g_bVelocity)
TeleportEntity(client, g_fPlayerCords[client][actual], g_fPlayerAngles[client][actual], g_fPlayerVelocity[client][actual]);
else TeleportEntity(client, g_fPlayerCords[client][actual], g_fPlayerAngles[client][actual], Float:{0.0,0.0,-100.0});//stop him
PrintToChat(client, "%t", "CpTeleported", YELLOW,LIGHTGREEN,YELLOW,GREEN,actual+1,whole,YELLOW);
g_CurrentCp[client] += pos;

if(g_bEffects)
{
EmitSoundToClient(client,"buttons/blip1.wav",client);
TE_SetupBeamRingPoint(g_fPlayerCords[client][actual],10.0,200.0,g_BeamSpriteRing2,0,0,10,1.0,50.0,0.0,{255,255,255,255},0,0);
TE_SendToClient(client);
}

Timer_SetClientLevel(client, g_iPlayerLevel[client][actual]);
EmitSoundToClient(client,"buttons/blip1.wav",client);
TE_SetupBeamRingPoint(g_fPlayerCords[client][actual],10.0,200.0,g_BeamSpriteRing2,0,0,10,1.0,50.0,0.0,{255,255,255,255},0,0);
TE_SendToClient(client);
}

Timer_SetClientLevel(client, g_iPlayerLevel[client][actual]);
}
else //plugin disabled
PrintToChat(client, "%t", "PluginDisabled", YELLOW,LIGHTGREEN,YELLOW);

return Plugin_Stop;
}

ConfirmAbortMenu(client, pos)
Expand Down
18 changes: 15 additions & 3 deletions gameserver/addons/sourcemod/scripting/cpMod/sql.sp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,11 @@ public db_insertPlayer(client){
decl String:szSteamId[32];
decl String:szUName[MAX_NAME_LENGTH];
//get some playerinformation
GetClientAuthString(client, szSteamId, 32);
#if SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 7
GetClientAuthId(client, AuthId_Steam2, szSteamId, sizeof(szSteamId));
#else
GetClientAuthString(client, szSteamId, sizeof(szSteamId));
#endif
GetClientName(client, szUName, MAX_NAME_LENGTH);

decl String:szName[MAX_NAME_LENGTH*2+1];
Expand All @@ -161,7 +165,11 @@ public db_updatePlayerCheckpoint(client, current){
decl String:szSteamId[32];
//get some playerinformation
GetClientName(client, szUName, MAX_NAME_LENGTH);
GetClientAuthString(client, szSteamId, 32);
#if SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 7
GetClientAuthId(client, AuthId_Steam2, szSteamId, sizeof(szSteamId));
#else
GetClientAuthString(client, szSteamId, sizeof(szSteamId));
#endif

decl String:szName[MAX_NAME_LENGTH*2+1];
//escape some quote characters that could mess up the szQuery
Expand Down Expand Up @@ -200,7 +208,11 @@ public SQL_SelectPlayerCallback(Handle:owner, Handle:hndl, const String:error[],
public db_selectPlayerCheckpoint(client){
decl String:szQuery[255];
decl String:szSteamId[32];
GetClientAuthString(client, szSteamId, 32);
#if SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 7
GetClientAuthId(client, AuthId_Steam2, szSteamId, sizeof(szSteamId));
#else
GetClientAuthString(client, szSteamId, sizeof(szSteamId));
#endif

Format(szQuery, 255, sql_selectCheckpoint, szSteamId, g_szMapName);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#include <sourcemod>
#include <sdktools>
#include <smlib>
#include <morecolors>
#include <timer>

public OnPluginStart()
{
HookEntityOutput( "func_button", "OnPressed", pressed);
HookEntityOutput( "func_button", "OnDamaged", damaged);
}

public OnMapStart()
{
HookEntityOutput( "func_button", "OnPressed", pressed);
HookEntityOutput( "func_button", "OnDamaged", damaged);
}

public OnMapEnd()
{
UnhookEntityOutput( "func_button", "OnPressed", pressed);
UnhookEntityOutput( "func_button", "OnDamaged", damaged);
}


public damaged(const String:output[], caller, attacker, Float:Any)
{
if(Client_IsValid(attacker, true)) CPrintToChat(attacker, "%s {yellow}You have shot a button.", PLUGIN_PREFIX2);
}

public pressed(const String:output[], caller, attacker, Float:Any)
{
if(Client_IsValid(attacker, true) && Client_HasButtons(attacker, IN_USE)) CPrintToChat(attacker, "%s {yellow}You have pressed a button.", PLUGIN_PREFIX2);
}
Loading