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

Respawn plugin edit


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Trafikkz
Junior Member
Join Date: Apr 2010
Old 05-12-2011 , 08:13   Respawn plugin edit
Reply With Quote #1

Well...let me expalin the scripting. I have a plugin that when you type /respawn it will respawn you. But I want to make this different. I want when the player dies to show him a message for example "You have X more seconds to press any key or you will be moved to spectators." and then if the user press any key (A, W, S, D, mouse click, any key from the keyboard) will respawn him, otherwise he will be moved to spectators.

This is the plugin:

Code:
/* AMXX Mod script.
*
* (c) Copyright 2004, developed by Geesu
* This file is provided as is (no warranties). 
*
* Changelog
* 1.1:
*   Added /respawn command to spawn a player if they're dead
*   Added a public cvar
* 1.0: 
*    Pistols are now given to players when they respawn
*    sv_checkpistols cvar added, if this is set to 0, then players will always spawn with a pistol, otherwise they will only spawn with a pistol when it is not scoutzknivez and not a ka map
*    sv_respawn cvar added, set this to 0 to disable the plugin
*/

new const VERSION[] =    "1.1"

#include <amxmodx>
#include <fun>
#include <cstrike>

#define DISABLE_CS 0

// team ids 
#define UNASSIGNED 0 
#define TS 1 
#define CTS 2 
#define AUTO_TEAM 5 

#define TASK_CD 36663

new bool:g_PistolsDisabled = false
new g_TimeCount = 30;

public plugin_init(){

    register_plugin("Respawn Forever", VERSION, "Pimp Daddy (OoTOAoO)")

    register_event("DeathMsg","on_Death","a")
    
    register_cvar("sv_checkpistols", "1")
    register_cvar("sv_respawn", "1")
    register_cvar("respawn_forever_version", VERSION, FCVAR_SERVER)

    register_clcmd("say","on_Chat")
    register_clcmd("say_team","on_Chat")
}

public on_Chat(id)
{
    if ( !get_cvar_num("sv_respawn") )
    {
        client_print(id, print_chat, "* Respawn plugin disabled")
        return PLUGIN_CONTINUE
    }

    new szSaid[32]
    read_args(szSaid, 31) 

    /*if (equali(szSaid,"^"/respawn^"") || equali(szSaid,"^"respawn^""))
    {
        spawn_func(id)
    }*/
    
    return PLUGIN_HANDLED;
}

public check_pistols()
{
    /* Determine if we should give players a pistol or not */
    if ( get_cvar_num("sv_checkpistols") )
    {
        set_task(1.0, "check_pistols")
        new mapname[32]
        get_mapname(mapname,31) 
        if ( containi(mapname,"ka_")!=-1 || containi(mapname,"scoutzknivez")!=-1 )
                g_PistolsDisabled = true
    }
}

public spawn_func(id)
{
    new parm[1]
    parm[0]=id
    
    /* Spawn the player twice to avoid the HL engine bug */
    set_task(0.5,"player_spawn",72,parm,1)
    set_task(0.7,"player_spawn",72,parm,1)

    /* Then give them a suit and a knife */
    set_task(0.9,"player_giveitems",72,parm,1)
}

public on_Death()
{
    if (!get_cvar_num("sv_respawn"))
        return PLUGIN_CONTINUE
    
    new victim_id = read_data(2)
    spawn_func( victim_id )

    return PLUGIN_CONTINUE
}

public player_giveitems(parm[1])
{
    new id = parm[0]

    give_item(id, "item_suit")
    give_item(id, "weapon_knife")
    
    /*set_user_godmode(id, 1);
    cs_set_user_money(id, 16000);
    set_user_rendering(id,kRenderFxGlowShell,255,255,255,kRenderNormal,25) 
    set_task(2.0, "RemoveAllGoodies");*/

    /* Determines if a players should be given a pistol */
    if ( !g_PistolsDisabled )
    {
        new wpnList[32] = 0, number = 0, bool:foundGlock = false, bool:foundUSP = false 
        get_user_weapons(id,wpnList,number)
        
        /* Determine if the player already has a pistol */
        for (new i = 0;i < number;i++)
        { 
            if (wpnList[i] == CSW_GLOCK18) 
                foundGlock = true 
            if (wpnList[i] == CSW_USP) 
                foundUSP = true 
        }
        
        /* Give a T his/her pistol */
        if ( get_user_team(id)==TS && !foundGlock )
        {
                give_item(id,"weapon_glock18")
                give_item(id,"ammo_9mm")
                give_item(id,"ammo_9mm")
        }
        /* Give a CT his/her pistol */
        else if ( get_user_team(id)==CTS && !foundUSP )
        {
                give_item(id,"weapon_usp")
                give_item(id,"ammo_45acp")
                give_item(id,"ammo_45acp")
        }
    }

    return PLUGIN_CONTINUE
}

public player_spawn(parm[1])
{
    spawn(parm[0])
}

/*public RemoveAllGoodies(id)
{
    set_user_godmode(id);
    set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderNormal,25) 
    
    return PLUGIN_HANDLED;
}*/
I really need some help. The coutdown I know how to make, but the part with keypress ... I don't know it yet.
Trafikkz is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 05-12-2011 , 09:11   Re: Respawn plugin edit
Reply With Quote #2

In public on_Death replace spawn_func with client_print(id, print_chat, "You have X more seconds to press any key or you will be moved to spectators.") and also add function "move_to_spectator" that will move him to spectators and call it via set_task (in public on_Death). Then, hook cmd_start with fakemeta, and if player team is not spectacor and not unassigned, then respawn him and remove "move_to_spectator" task.
__________________

SonicSonedit is offline
Trafikkz
Junior Member
Join Date: Apr 2010
Old 05-12-2011 , 11:55   Re: Respawn plugin edit
Reply With Quote #3

You didn't understood what I want....well let me explain more. The player dies, but remains in his team with the status DEAD. At this moment it will appear a hud message that says 'If you don't press any key in X seconds you will be moved to spectators.' For example, the seconds are 20. If in 20 seconds he don't press any button, then he will be moved to spectators.
Trafikkz is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 05-12-2011 , 15:08   Re: Respawn plugin edit
Reply With Quote #4

Trafikkz
It's actually you who didn't understand what I said. Read my post once again. If you want hudmessage, use set/show_hudmessage instead of client_print.
__________________

SonicSonedit is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-12-2011 , 18:54   Re: Respawn plugin edit
Reply With Quote #5

Yep, Sonic's method describes is how I would do it also.
__________________
fysiks is online now
Trafikkz
Junior Member
Join Date: Apr 2010
Old 05-13-2011 , 07:49   Re: Respawn plugin edit
Reply With Quote #6

Thanks, I have read as 'Then, hook cmd_start and if is spectator or the team is unassigned he will get respawn' so I said wtf? Thanks, the topic can be closed.
Trafikkz is offline
Trafikkz
Junior Member
Join Date: Apr 2010
Old 05-13-2011 , 15:59   Re: Respawn plugin edit
Reply With Quote #7

Sorry for double post but I'm stuck. Look at what I've done, but it doesn't work. The server freezes when I press a button.

Code:
/* AMXX Mod script.
*
* (c) Copyright 2004, developed by Geesu
* This file is provided as is (no warranties). 
*
* Changelog
* 1.1:
*   Added /respawn command to spawn a player if they're dead
*   Added a public cvar
* 1.0: 
*    Pistols are now given to players when they respawn
*    sv_checkpistols cvar added, if this is set to 0, then players will always spawn with a pistol, otherwise they will only spawn with a pistol when it is not scoutzknivez and not a ka map
*    sv_respawn cvar added, set this to 0 to disable the plugin
*/

new const VERSION[] =    "1.1"

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <fun>
#include <engine>
#include <cstrike>

#define DISABLE_CS 0

// team ids 
#define UNASSIGNED 0 
#define TS 1 
#define CTS 2 
#define AUTO_TEAM 5 

#define TID 36663
new g_Num = 20;

new bool:g_PistolsDisabled = false
new bool:gClientDead[33]

public plugin_init(){

    register_plugin("Respawn Forever", VERSION, "Pimp Daddy (OoTOAoO)")

    register_event("DeathMsg","on_Death","a")
    
    register_cvar("sv_checkpistols", "1")
    register_cvar("sv_respawn", "1")
    register_cvar("respawn_forever_version", VERSION, FCVAR_SERVER)

    register_clcmd("say","on_Chat")
    register_clcmd("say_team","on_Chat")
    register_forward(FM_CmdStart, "Hook_Buttons");
}

public Hook_Buttons(ClientID, UC_Handle)
{
    if(gClientDead[ClientID])
    {
        static Button;
        Button = get_uc(UC_Handle, UC_Buttons);
        if(Button)
        {
            if(task_exists(TID))
            {
                remove_task(TID);
            }
            spawn_func(ClientID);
        }
    }
    
    return FMRES_SUPERCEDE;
}

public on_Chat(id)
{
    if ( !get_cvar_num("sv_respawn") )
    {
        client_print(id, print_chat, "* Respawn plugin disabled")
        return PLUGIN_CONTINUE
    }

    new szSaid[32]
    read_args(szSaid, 31) 

    /*if (equali(szSaid,"^"/respawn^"") || equali(szSaid,"^"respawn^""))
    {
        spawn_func(id)
    }*/
    
    return PLUGIN_HANDLED;
}

public check_pistols()
{
    /* Determine if we should give players a pistol or not */
    if ( get_cvar_num("sv_checkpistols") )
    {
        set_task(1.0, "check_pistols")
        new mapname[32]
        get_mapname(mapname,31) 
        if ( containi(mapname,"ka_")!=-1 || containi(mapname,"scoutzknivez")!=-1 )
                g_PistolsDisabled = true
    }
}

public spawn_func(id)
{
    new parm[1]
    parm[0]=id
    
    gClientDead[id] = false
    
    /* Spawn the player twice to avoid the HL engine bug */
    set_task(0.5,"player_spawn",72,parm,1)
    set_task(0.7,"player_spawn",72,parm,1)

    /* Then give them a suit and a knife */
    set_task(0.9,"player_giveitems",72,parm,1)
}

public on_Death()
{
    if (!get_cvar_num("sv_respawn"))
        return PLUGIN_CONTINUE
    
    new victim_id = read_data(2)
    //spawn_func( victim_id )
    
    gClientDead[victim_id] = true
    
    //set_task(0.8, "count_it_down", TID, data_to_send, 1);
    set_task(1.0, "count_it_down", TID, _, _, "b", 0);
    

    return PLUGIN_CONTINUE
}

public count_it_down(id)
{
    set_hudmessage(255, 255, 0, -1.0, -1.0, 0, 6.0, 1.0, 0.1, 0.1, 1)
    show_hudmessage(id, "Apasati tasta W pentru respawn^nDaca nu reactionati in %d secunde veti fi mutat la spectator.", g_Num)
    g_Num++
    if(g_Num <= 0)
    {
        if(task_exists(TID))
        {
            remove_task(TID);
            return;
        }
        
        cs_set_user_team(id, CS_TEAM_SPECTATOR);
        gClientDead[id] = false
    }
    
    return;
}    

public player_giveitems(parm[1])
{
    new id = parm[0]

    give_item(id, "item_suit")
    give_item(id, "weapon_knife")
    set_user_godmode(id, 1)
    cs_set_user_money(id, 16000);
    set_user_rendering(id,kRenderFxGlowShell,255,255,255,kRenderNormal,25)
    set_task(3.0, "remove_given_tasks", _, parm, 1);
    
    /*set_user_godmode(id, 1);
    cs_set_user_money(id, 16000);
    set_user_rendering(id,kRenderFxGlowShell,255,255,255,kRenderNormal,25) 
    set_task(2.0, "RemoveAllGoodies");*/

    /* Determines if a players should be given a pistol */
    if ( !g_PistolsDisabled )
    {
        new wpnList[32] = 0, number = 0, bool:foundGlock = false, bool:foundUSP = false 
        get_user_weapons(id,wpnList,number)
        
        /* Determine if the player already has a pistol */
        for (new i = 0;i < number;i++)
        { 
            if (wpnList[i] == CSW_GLOCK18) 
                foundGlock = true 
            if (wpnList[i] == CSW_USP) 
                foundUSP = true 
        }
        
        /* Give a T his/her pistol */
        if ( get_user_team(id)==TS && !foundGlock )
        {
                give_item(id,"weapon_glock18")
                give_item(id,"ammo_9mm")
                give_item(id,"ammo_9mm")
        }
        /* Give a CT his/her pistol */
        else if ( get_user_team(id)==CTS && !foundUSP )
        {
                give_item(id,"weapon_usp")
                give_item(id,"ammo_45acp")
                give_item(id,"ammo_45acp")
        }
    }

    return PLUGIN_CONTINUE
}

public player_spawn(parm[1])
{
    spawn(parm[0])
}

public remove_given_tasks(id)
{
    set_user_godmode(id)
    set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderNormal,25)
    
    return PLUGIN_HANDLED;
}

/*public RemoveAllGoodies(id)
{
    set_user_godmode(id);
    set_user_rendering(id,kRenderFxGlowShell,0,0,0,kRenderNormal,25) 
    
    return PLUGIN_HANDLED;
}*/
So where I edited/add is: on_death, hook_button, spawn_func, players_giveitems, remove_given_tasks, plugin-init - I don't get errors at compiling
Trafikkz is offline
SonicSonedit
Veteran Member
Join Date: Nov 2008
Location: Silent Hill
Old 05-13-2011 , 16:07   Re: Respawn plugin edit
Reply With Quote #8

Try this:
PHP Code:
public Hook_Buttons(ClientIDUC_Handle)
{
    if(
gClientDead[ClientID])
        if (
get_uc(UC_HandleUC_Buttons)&&task_exists(TID))
        {       
                
gClientDead[ClientID]=false
                spawn_func
(ClientID)
                
remove_task(TID).
        }

    return 
FMRES_IGNORED;

__________________

SonicSonedit is offline
Trafikkz
Junior Member
Join Date: Apr 2010
Old 05-14-2011 , 17:32   Re: Respawn plugin edit
Reply With Quote #9

It doesn't work....I don't press any key and I get respawn.
Trafikkz is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 05-14-2011 , 17:49   Re: Respawn plugin edit
Reply With Quote #10

If you hook FCanPlayerRespawn with orpheu and you return true, then player is respawned like 1.5 second after death, unless he's pressing a button.
If he is pressing a button he is put in spec mode.

Would this fit your needs ? (would be more efficient)
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Reply



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 15:16.


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