Removed SetPlayerModel, removed deprecated code in models.txt, added CSWeaponDrop, updated gamedata file.

This commit is contained in:
Greycale 2009-04-15 21:22:11 +02:00
parent c8989eb544
commit 37dfea2f8c
5 changed files with 230 additions and 203 deletions

View File

@ -1,33 +1,48 @@
"Games" "Games"
{ {
"cstrike" "#default"
{ {
"Offsets" "#supported"
{ {
"RemoveAllItems" "game" "cstrike"
{ }
"windows" "283"
"linux" "284" "Offsets"
} {
"EyePosition" "RemoveAllItems"
{ {
"windows" "117" "windows" "283"
"linux" "118" "linux" "284"
} }
"EyeAngles"
{ "EyePosition"
"windows" "206" {
"linux" "207" "windows" "117"
} "linux" "118"
} }
"Signatures"
{ "EyeAngles"
"TerminateRound" {
{ "windows" "206"
"library" "server" "linux" "207"
"windows" "\x83\xEC\x18\x53\x55\x8B\xD9\x8B\x4C\x24\x28\x56\x57\x33\xF6\x8D" }
"linux" "@_ZN12CCSGameRules14TerminateRoundEfi" }
}
} "Signatures"
} {
"TerminateRound"
{
"library" "server"
"windows" "\x83\xEC\x18\x53\x55\x8B\xD9\x8B\x4C\x24\x28\x56\x57\x33\xF6\x8D"
"linux" "@_ZN12CCSGameRules14TerminateRoundEfi"
}
"CSWeaponDrop"
{
"library" "server"
"windows" "\x2A\x2A\x2A\x2A\x2A\x2A\x53\x55\x56\x57\x8B\xBC\x24\x40\x01\x00\x00\x32\xDB\x85\xFF\x8B\xF1\x0F"
"linux" "@_ZN9CCSPlayer12CSWeaponDropEP17CBaseCombatWeaponbb"
}
}
}
} }

View File

@ -115,25 +115,3 @@ LoadDownloadData()
CloseHandle(fileDownloads); CloseHandle(fileDownloads);
CloseHandle(arrayDownloads); CloseHandle(arrayDownloads);
} }
/*ApplyZombieModel(client)
{
decl String:modelpath[256];
new bool:classes = GetConVarBool(gCvars[CVAR_CLASSES]);
if (classes)
{
GetClassModel(pClass[client], modelpath, sizeof(modelpath));
if (!StrEqual(modelpath, "default", false))
{
SetPlayerModel(client, modelpath);
return;
}
}
new randmodel = GetRandomInt(0, GetArraySize(arrayModels) - 1);
GetArrayString(arrayModels, randmodel, modelpath, sizeof(modelpath));
Format(modelpath, sizeof(modelpath), "%s.mdl", modelpath);
SetPlayerModel(client, modelpath);
}*/

View File

@ -21,9 +21,10 @@ new offsRender;
new Handle:g_hGameConf = INVALID_HANDLE; new Handle:g_hGameConf = INVALID_HANDLE;
new Handle:g_hRemoveAllItems = INVALID_HANDLE; new Handle:g_hRemoveAllItems = INVALID_HANDLE;
new Handle:g_hTerminateRound = INVALID_HANDLE;
new Handle:g_hEyePosition = INVALID_HANDLE; new Handle:g_hEyePosition = INVALID_HANDLE;
new Handle:g_hEyeAngles = INVALID_HANDLE; new Handle:g_hEyeAngles = INVALID_HANDLE;
new Handle:g_hTerminateRound = INVALID_HANDLE;
new Handle:g_hCSWeaponDrop = INVALID_HANDLE;
FindOffsets() FindOffsets()
{ {
@ -100,27 +101,61 @@ FindOffsets()
SetupGameData() SetupGameData()
{ {
// Load game config file.
g_hGameConf = LoadGameConfigFile("plugin.zombiereloaded"); g_hGameConf = LoadGameConfigFile("plugin.zombiereloaded");
//
StartPrepSDKCall(SDKCall_Player); StartPrepSDKCall(SDKCall_Player);
PrepSDKCall_SetFromConf(g_hGameConf, SDKConf_Virtual, "RemoveAllItems"); PrepSDKCall_SetFromConf(g_hGameConf, SDKConf_Virtual, "RemoveAllItems");
g_hRemoveAllItems = EndPrepSDKCall(); g_hRemoveAllItems = EndPrepSDKCall();
if(g_hRemoveAllItems == INVALID_HANDLE)
{
SetFailState("Couldn't find offset \"RemoveAllItems\"!");
}
StartPrepSDKCall(SDKCall_Player); StartPrepSDKCall(SDKCall_Player);
PrepSDKCall_SetFromConf(g_hGameConf, SDKConf_Virtual, "EyePosition"); PrepSDKCall_SetFromConf(g_hGameConf, SDKConf_Virtual, "EyePosition");
PrepSDKCall_SetReturnInfo(SDKType_QAngle, SDKPass_ByValue); PrepSDKCall_SetReturnInfo(SDKType_QAngle, SDKPass_ByValue);
g_hEyePosition = EndPrepSDKCall(); g_hEyePosition = EndPrepSDKCall();
if(g_hEyePosition == INVALID_HANDLE)
{
SetFailState("Couldn't find offset \"EyePosition\"!");
}
StartPrepSDKCall(SDKCall_Player); StartPrepSDKCall(SDKCall_Player);
PrepSDKCall_SetFromConf(g_hGameConf, SDKConf_Virtual, "EyeAngles"); PrepSDKCall_SetFromConf(g_hGameConf, SDKConf_Virtual, "EyeAngles");
PrepSDKCall_SetReturnInfo(SDKType_QAngle, SDKPass_ByValue); PrepSDKCall_SetReturnInfo(SDKType_QAngle, SDKPass_ByValue);
g_hEyeAngles = EndPrepSDKCall(); g_hEyeAngles = EndPrepSDKCall();
if(g_hEyeAngles == INVALID_HANDLE)
{
SetFailState("Couldn't find offset \"EyeAngles\"!");
}
StartPrepSDKCall(SDKCall_GameRules); StartPrepSDKCall(SDKCall_GameRules);
PrepSDKCall_SetFromConf(g_hGameConf, SDKConf_Signature, "TerminateRound"); PrepSDKCall_SetFromConf(g_hGameConf, SDKConf_Signature, "TerminateRound");
PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain); PrepSDKCall_AddParameter(SDKType_Float, SDKPass_Plain);
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain); PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
g_hTerminateRound = EndPrepSDKCall(); g_hTerminateRound = EndPrepSDKCall();
if(g_hTerminateRound == INVALID_HANDLE)
{
SetFailState("Couldn't find signature \"CGameRules::TerminateRound\"!");
}
StartPrepSDKCall(SDKCall_Player);
PrepSDKCall_SetFromConf(g_hGameConf, SDKConf_Signature, "CSWeaponDrop");
PrepSDKCall_AddParameter(SDKType_CBaseEntity, SDKPass_Pointer);
PrepSDKCall_AddParameter(SDKType_Bool, SDKPass_Plain);
PrepSDKCall_AddParameter(SDKType_Bool, SDKPass_Plain);
g_hCSWeaponDrop = EndPrepSDKCall();
if(g_hCSWeaponDrop == INVALID_HANDLE)
{
SetFailState("Couldn't find signature \"CBasePlayer::CSWeaponDrop\"!");
}
} }
SetPlayerVelocity(client, const Float:vec[3], bool:reset) SetPlayerVelocity(client, const Float:vec[3], bool:reset)
@ -231,13 +266,12 @@ GetPlayerEyeAngles(client, Float:ang[3])
TerminateRound(Float:delay, reason) TerminateRound(Float:delay, reason)
{ {
if (g_hTerminateRound == INVALID_HANDLE) return;
SDKCall(g_hTerminateRound, delay, reason); SDKCall(g_hTerminateRound, delay, reason);
} }
SetPlayerModel(client, const String:model[]) CSDropWeapon(client, weapon)
{ {
SetEntityModel(client, model); SDKCall(g_hCSWeaponDrop, client, weapon, true, false);
} }
SetPlayerAlpha(client, alpha) SetPlayerAlpha(client, alpha)

View File

@ -78,7 +78,7 @@ bool:ClassApplyModel(client, classindex, cachetype = ZR_CLASS_CACHE_PLAYER)
// TODO: Add support for keeping the default cs model ("default"). // TODO: Add support for keeping the default cs model ("default").
SetPlayerModel(client, modelpath); SetEntityModel(client, modelpath);
return true; return true;
} }

View File

@ -1,145 +1,145 @@
/* /*
* ============================================================================ * ============================================================================
* *
* Zombie:Reloaded * Zombie:Reloaded
* *
* File: spawnprotect.inc * File: spawnprotect.inc
* Description: Protects late-joining players from zombies for x seconds. * Description: Protects late-joining players from zombies for x seconds.
* *
* ============================================================================ * ============================================================================
*/ */
/** /**
* Array for storing spawn protect timer handles per client. * Array for storing spawn protect timer handles per client.
*/ */
new Handle:tSpawnProtect[MAXPLAYERS + 1]; new Handle:tSpawnProtect[MAXPLAYERS + 1];
/** /**
* Array for flagging client to be protected. * Array for flagging client to be protected.
*/ */
new bool:pSpawnProtect[MAXPLAYERS + 1]; new bool:pSpawnProtect[MAXPLAYERS + 1];
/** /**
* Array for storing time left for spawn protection per client. * Array for storing time left for spawn protection per client.
*/ */
new pSpawnProtectTime[MAXPLAYERS + 1]; new pSpawnProtectTime[MAXPLAYERS + 1];
/** /**
* Client is joining the server. * Client is joining the server.
* *
* @param client The client index. * @param client The client index.
*/ */
SpawnProtectClientInit(client) SpawnProtectClientInit(client)
{ {
tSpawnProtect[client] = INVALID_HANDLE; tSpawnProtect[client] = INVALID_HANDLE;
} }
/** /**
* Player is spawning into the game. * Player is spawning into the game.
* *
* @param client The client index. * @param client The client index.
*/ */
SpawnProtectPlayerSpawn(client) SpawnProtectPlayerSpawn(client)
{ {
// Disable spawn protection on client. // Disable spawn protection on client.
pSpawnProtect[client] = false; pSpawnProtect[client] = false;
// If zombie hasn't spawned, then stop. // If zombie hasn't spawned, then stop.
if (!zombieSpawned) if (!zombieSpawned)
{ {
return; return;
} }
// If protect cvar is invalid or 0, then stop. // If protect cvar is invalid or 0, then stop.
new protect = GetConVarInt(gCvars[CVAR_PROTECT]); new protect = GetConVarInt(gCvars[CVAR_PROTECT]);
if (protect <= 0) if (protect <= 0)
{ {
return; return;
} }
// Get respawn team. // Get respawn team.
decl String:respawnteam[32]; decl String:respawnteam[32];
GetConVarString(gCvars[CVAR_RESPAWN_TEAM], respawnteam, sizeof(respawnteam)); GetConVarString(gCvars[CVAR_RESPAWN_TEAM], respawnteam, sizeof(respawnteam));
// If the respawn team is not set to zombie, and either cvar zr_suicide_world_damage or the client // If the respawn team is not set to zombie, and either cvar zr_suicide_world_damage or the client
// wasn't killed by world is false, then continue to protect client. // wasn't killed by world is false, then continue to protect client.
if (!StrEqual(respawnteam, "zombie", false) && !(GetConVarBool(gCvars[CVAR_SUICIDE_WORLD_DAMAGE]) && gKilledByWorld[client])) if (!StrEqual(respawnteam, "zombie", false) && !(GetConVarBool(gCvars[CVAR_SUICIDE_WORLD_DAMAGE]) && gKilledByWorld[client]))
{ {
// Set spawn protect flag on client. // Set spawn protect flag on client.
pSpawnProtect[client] = true; pSpawnProtect[client] = true;
// Set improved attributes // Set improved attributes
// (Move to cvar?) // (Move to cvar?)
SetPlayerAlpha(client, 0); SetPlayerAlpha(client, 0);
SetPlayerSpeed(client, 600.0); SetPlayerSpeed(client, 600.0);
// Set time left to zr_protect's value. // Set time left to zr_protect's value.
pSpawnProtectTime[client] = protect; pSpawnProtectTime[client] = protect;
// Tell client they are being protected. // Tell client they are being protected.
ZR_PrintToChat(client, "Spawn protection begin", protect); ZR_PrintToChat(client, "Spawn protection begin", protect);
// Send time left in a hud message. // Send time left in a hud message.
ZR_HudHint(client, "Spawn Protect", pSpawnProtectTime[client]); ZR_HudHint(client, "Spawn Protect", pSpawnProtectTime[client]);
// If timer is currently running, kill it. // If timer is currently running, kill it.
if (tSpawnProtect[client] != INVALID_HANDLE) if (tSpawnProtect[client] != INVALID_HANDLE)
{ {
KillTimer(tSpawnProtect[client]); KillTimer(tSpawnProtect[client]);
} }
// Start repeating timer. // Start repeating timer.
tSpawnProtect[client] = CreateTimer(1.0, SpawnProtectTimer, client, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT); tSpawnProtect[client] = CreateTimer(1.0, SpawnProtectTimer, client, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT);
} }
} }
/** /**
* Timer callback function, countdown for spawn protection. * Timer callback function, countdown for spawn protection.
* *
* @param timer The timer handle. * @param timer The timer handle.
* @param client The client index. * @param client The client index.
*/ */
public Action:SpawnProtectTimer(Handle:timer, any:client) public Action:SpawnProtectTimer(Handle:timer, any:client)
{ {
// If client leaves, then stop timer. // If client leaves, then stop timer.
if (!IsClientInGame(client)) if (!IsClientInGame(client))
{ {
return Plugin_Stop; return Plugin_Stop;
} }
// If client has become a zombie, then stop timer. // If client has become a zombie, then stop timer.
if (!IsPlayerHuman(client)) if (!IsPlayerHuman(client))
{ {
return Plugin_Stop; return Plugin_Stop;
} }
// Decrement time left. // Decrement time left.
pSpawnProtectTime[client]--; pSpawnProtectTime[client]--;
// Print time left to client. // Print time left to client.
ZR_HudHint(client, "Spawn Protect", pSpawnProtectTime[client]); ZR_HudHint(client, "Spawn Protect", pSpawnProtectTime[client]);
// Time has expired. // Time has expired.
if (pSpawnProtectTime[client] <= 0) if (pSpawnProtectTime[client] <= 0)
{ {
// Remove protect flag. // Remove protect flag.
pSpawnProtect[client] = false; pSpawnProtect[client] = false;
// Tell client spawn protection is over. // Tell client spawn protection is over.
ZR_HudHint(client, "Spawn protection end"); ZR_HudHint(client, "Spawn protection end");
// Fix attributes. // Fix attributes.
// TODO: Set class attributes. // TODO: Set class attributes.
SetPlayerAlpha(client, 255); SetPlayerAlpha(client, 255);
SetPlayerSpeed(client, 300.0); SetPlayerSpeed(client, 300.0);
// Clear timer handle. // Clear timer handle.
tSpawnProtect[client] = INVALID_HANDLE; tSpawnProtect[client] = INVALID_HANDLE;
// Stop timer. // Stop timer.
return Plugin_Stop; return Plugin_Stop;
} }
// Allow timer to continue repeating. // Allow timer to continue repeating.
return Plugin_Continue; return Plugin_Continue;
} }