Raised This Month: $12 Target: $400
 3% 

API Scripting Help Respawn on connect


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 07-11-2012 , 05:38   Respawn on connect
Reply With Quote #1

I have this plugins(look below), it works fine, but there is one thing that I don't want to happen - when there is last human they are still respawning, could anyone help me?
Attached Files
File Type: sma Get Plugin or Get Source (zp_respawn.sma - 800 views - 1.7 KB)
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
gogicaa
Veteran Member
Join Date: Aug 2011
Location: //
Old 07-11-2012 , 07:56   Re: Respawn on connect
Reply With Quote #2

Loop through all players , and check if someone is last human. if there is no last human , use return , else respawn connected player.

Last edited by gogicaa; 07-11-2012 at 08:33.
gogicaa is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 07-11-2012 , 13:04   Re: Respawn on connect
Reply With Quote #3

How to do that loop? I don't know much about scripting, is it just adding if statement?
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
Y060N
BANNED
Join Date: Dec 2011
Location: www.equilibriumcs.com
Old 07-11-2012 , 13:49   Re: Respawn on connect
Reply With Quote #4

No loop needed, there is a forward for it. And I don't really know why it's using an infinite task but I think this is better:

PHP Code:
#include <amxmodx>
#include <zombieplague>
#include <zp50_core>

#define validTeam(%1) (1 <= get_user_team(%1) <= 3)

#define TASK_SPAWN 5889
#define ID_SPAWN (taskid - TASK_SPAWN)

new pcvarpcvar_nempcvar_plaguepcvar_survpcvar_swarm;

new 
lastHuman

public plugin_init()
{
    
register_plugin("[ZP] Respawn""1.1""ILUSION");
    
    
register_event("HLTV""event_round_start""a""1=0""2=0")
    
    
pcvar get_cvar_pointer("zp_deathmatch");
    
pcvar_nem get_cvar_pointer("zp_nem_allow_respawn");
    
pcvar_plague get_cvar_pointer("zp_plague_allow_respawn");
    
pcvar_swarm get_cvar_pointer("zp_swarm_allow_respawn");
    
pcvar_surv get_cvar_pointer("zp_surv_allow_respawn");
}

public 
client_putinserver(id)
{
    if (!
lastHuman)
    {
        if (
zp_is_swarm_round() && !get_pcvar_num(pcvar_swarm) || zp_is_nemesis_round() && !get_pcvar_num(pcvar_nem))
            return
    
        if (
get_pcvar_num(pcvar))
            
set_task(12.0"SpawnUser"id TASK_SPAWN);
    }
}

public 
client_disconnect(id)
{
    if (
task_exists(id TASK_SPAWN))
        
remove_task(id TASK_SPAWN)
}

zp_fw_core_last_human(id)
{
    
lastHuman 1
}

public 
event_round_start()
{
    
lastHuman 0
}

public 
SpawnUser(taskid)
{
    new 
id ID_SPAWN
    
    
if (!is_user_connected(id) || is_user_alive(id) || !validTeam(id) || lastHuman)
        return
    else
    {
        switch (
get_pcvar_num(pcvar))
        {
            case 
1zp_respawn_user(idzp_is_survivor_round() ? ZP_TEAM_ZOMBIE ZP_TEAM_HUMAN);
            case 
2zp_respawn_user(idzp_is_nemesis_round() ? ZP_TEAM_HUMAN ZP_TEAM_ZOMBIE);
            case 
3zp_respawn_user(idzp_is_survivor_round() ? ZP_TEAM_ZOMBIE zp_is_nemesis_round() ? ZP_TEAM_HUMAN random_num(12) == ZP_TEAM_HUMAN ZP_TEAM_ZOMBIE);
            case 
4zp_respawn_user(idzp_is_survivor_round() ? ZP_TEAM_ZOMBIE zp_is_nemesis_round() ? ZP_TEAM_HUMAN zp_get_zombie_count() < zp_get_human_count() ? ZP_TEAM_ZOMBIE ZP_TEAM_HUMAN);
            default: 
zp_respawn_user(idzp_is_survivor_round() ? ZP_TEAM_ZOMBIE zp_is_nemesis_round() ? ZP_TEAM_HUMAN random_num(12) == ZP_TEAM_HUMAN ZP_TEAM_ZOMBIE);
        }
    }


Last edited by Y060N; 07-11-2012 at 13:56.
Y060N is offline
gogicaa
Veteran Member
Join Date: Aug 2011
Location: //
Old 07-11-2012 , 14:31   Re: Respawn on connect
Reply With Quote #5

Quote:
Originally Posted by Y060N View Post
No loop needed, there is a forward for it.
didnt knew that , thanks for that
gogicaa is offline
Y060N
BANNED
Join Date: Dec 2011
Location: www.equilibriumcs.com
Old 07-11-2012 , 18:42   Re: Respawn on connect
Reply With Quote #6

No problem Hope the version I posted works, I didn't test it

And you don't really need to check for is_user_connected because it removes the task when they are disconnected, but I just like to have it for safety since it's a pretty small check.
Y060N is offline
Old 07-13-2012, 18:37
GuskiS
This message has been deleted by GuskiS.
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 07-15-2012 , 15:34   Re: Respawn on connect
Reply With Quote #7

I'm sorry, but it doesn't work, players can still spawn if there is last human.
I'm also wondering about weapon plugins. How to add them knockback effect? Some off my added weapons have knockback, some of them don't. How to do it?
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
luankc
Junior Member
Join Date: Mar 2011
Old 07-19-2012 , 10:31   Re: Respawn on connect
Reply With Quote #8

How to fix?
Code:
L XX/XX/XX - XX:XX:XX: [AMXX] Displaying debug trace (plugin "zp_respawn.amxx")
L XX/XX/XX - XX:XX:XX: [AMXX] Run time error 10: native error (native "get_pcvar_num")
L XX/XX/XX - XX:XX:XX: [AMXX]    [0] zp_respawn.sma::SpawnUser (line 28)

Last edited by luankc; 07-19-2012 at 10:32.
luankc is offline
imgur
Junior Member
Join Date: Jul 2012
Old 07-20-2012 , 16:01   Re: Respawn on connect
Reply With Quote #9

i tink you gotta reinstall ploogin
imgur is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:29.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode