| myusername |
01-14-2014 11:59 |
Auto Respawn ZP
Need help with this code
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <zp50_core>
#include <zp50_gamemodes>
#define TASK_AUTORESPAWN 100
#define ID_AUTORESPAWN (taskid - TASK_AUTORESPAWN)
const Float:AUTORESPAWN_DELAY = 3.0
new _gGameModeNemesisID
,_gGameModeSurvivorID
,_gGameModeMultiID
,_gGameModeInfectionID
new _pCvarDeathMatch
new _gMaxPlayers
public plugin_init() {
register_clcmd("joinclass","cmd_joinclass")
register_menucmd(register_menuid("Terrorist_Select",1),511,"cmd_joinclass")
register_menucmd(register_menuid("CT_Select",1),511,"cmd_joinclass")
_pCvarDeathMatch = get_cvar_pointer("zp_deathmatch")
_gMaxPlayers = get_maxplayers()
}
public plugin_cfg() {
_gGameModeNemesisID = zp_gamemodes_get_id("Nemesis Mode")
_gGameModeSurvivorID = zp_gamemodes_get_id("Survivor Mode")
_gGameModeMultiID = zp_gamemodes_get_id("Multiple Infection Mode")
_gGameModeInfectionID = zp_gamemodes_get_id("Infection Mode")
}
public cmd_joinclass(id) {
if(zp_gamemodes_get_current() == _gGameModeInfectionID || zp_gamemodes_get_current() == _gGameModeMultiID) {
set_task(AUTORESPAWN_DELAY, "auto_respawn_player", id+TASK_AUTORESPAWN)
}
}
public auto_respawn_player(taskid) {
if (is_user_alive(ID_AUTORESPAWN))
return;
if( zp_gamemodes_get_current() == _gGameModeSurvivorID ) {
zp_core_respawn_as_zombie(ID_AUTORESPAWN, true)
}
else if( zp_gamemodes_get_current() == _gGameModeNemesisID ) {
zp_core_respawn_as_zombie(ID_AUTORESPAWN, false)
}
else if (get_pcvar_num(_pCvarDeathMatch) == 2 || (get_pcvar_num(_pCvarDeathMatch) == 3 && random_num(0, 1)) || (get_pcvar_num(_pCvarDeathMatch) == 4 && zp_core_get_zombie_count() < fnGetAlive()/2)) {
zp_core_respawn_as_zombie(ID_AUTORESPAWN, true)
}
else {
zp_core_respawn_as_zombie(ID_AUTORESPAWN, false)
}
ExecuteHamB(Ham_CS_RoundRespawn, ID_AUTORESPAWN)
}
fnGetAlive() {
new iAlive, id
for (id = 1; id <= _gMaxPlayers; id++) {
if (is_user_alive(id))
iAlive++
}
return iAlive;
}
Gives me this error
PHP Code:
L 01/14/2014 - 15:37:02: [AMXX] Invalid Player (11)
L 01/14/2014 - 15:37:02: [AMXX] Displaying debug trace (plugin "AutoRespawn.amxx")
L 01/14/2014 - 15:37:02: [AMXX] Run time error 10: native error (native "zp_core_respawn_as_zombie")
L 01/14/2014 - 15:37:02: [AMXX] [0] AutoRespawn.sma::auto_respawn_player (line 57)
Im using zp5.0.8. And also i don't use zp4.3 compat.
Thanks.
|