AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Need respawn plugin that asks if u want to respawn (https://forums.alliedmods.net/showthread.php?t=322713)

Pizzadaking 04-02-2020 14:57

Need respawn plugin that asks if u want to respawn
 
So i just want an respawn plugin that asks the player that died if the player wants to respawn or not as the plugin in the picture
https://i.imgur.com/LKzJBQL.jpg

Nutu_ 04-02-2020 18:44

Re: Need respawn plugin that asks if u want to respawn
 
bb (basebuilder) already respawns someone when he/she dies, just asking, if it already respawns you, why would you need that?

Napoleon_be 04-03-2020 06:53

Re: Need respawn plugin that asks if u want to respawn
 
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

#define PLUGIN "RespawnMenu"
#define VERSION "1.0"
#define AUTHOR "NapoleoN#"

new szMenu;
new 
iTeam;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
RegisterHam(Ham_Killed"player""PostPlayerKilled"1);
    
    
szMenu menu_create("\w[\rBB\w]\y Respawn?""RespawnHandler");
    
    
menu_additem(szMenu"\wYes");
    
menu_additem(szMenu"\wNo");
    
    
menu_setprop(szMenuMPROP_NUMBER_COLOR"\r");
}

public 
PostPlayerKilled(iVictimiAttackeriShouldGib)
{
    
iTeam get_user_team(iVictim);
    
    if(!
is_user_alive(iVictim) && (iTeam == || iTeam == 2))
    {
        
menu_display(iVictimszMenu)
    }
}

public 
RespawnHandler(idszMenuitem)
{
    
iTeam get_user_team(id);
    
    if(!
is_user_alive(id) && (iTeam == || iTeam == 2))
    {
        switch(
item)
        {
            case 
0ExecuteHamB(Ham_CS_RoundRespawnid);
            case 
1: return PLUGIN_HANDLED;
        }
    }
    return 
PLUGIN_HANDLED



wy19850 04-04-2020 13:03

Re: Need respawn plugin that asks if u want to respawn
 
Quote:

Originally Posted by Napoleon_be (Post 2690285)
PHP Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

#define PLUGIN "RespawnMenu"
#define VERSION "1.0"
#define AUTHOR "NapoleoN#"

new szMenu;
new 
iTeam;

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR);
    
    
RegisterHam(Ham_Killed"player""PostPlayerKilled"1);
    
    
szMenu menu_create("\w[\rBB\w]\y Respawn?""RespawnHandler");
    
    
menu_additem(szMenu"\wYes");
    
menu_additem(szMenu"\wNo");
    
    
menu_setprop(szMenuMPROP_NUMBER_COLOR"\r");
}

public 
PostPlayerKilled(iVictimiAttackeriShouldGib)
{
    
iTeam get_user_team(iVictim);
    
    if(!
is_user_alive(iVictim) && (iTeam == || iTeam == 2))
    {
        
menu_display(iVictimszMenu)
    }
}

public 
RespawnHandler(idszMenuitem)
{
    
iTeam get_user_team(id);
    
    if(!
is_user_alive(id) && (iTeam == || iTeam == 2))
    {
        switch(
item)
        {
            case 
0ExecuteHamB(Ham_CS_RoundRespawnid);
            case 
1: return PLUGIN_HANDLED;
        }
    }
    return 
PLUGIN_HANDLED






In CS1.5 test collapse, CS1.6 without option is and is not, come back. Again, optimization, CS1.5 run it. thank you

Bugsy 04-04-2020 13:26

Re: Need respawn plugin that asks if u want to respawn
 
Added some non-functional tweaks & comments to that code.
PHP Code:


#include <amxmodx>
#include <cstrike>
#include <hamsandwich>

#define PLUGIN "RespawnMenu"
#define VERSION "1.0"
#define AUTHOR "NapoleoN#"

//Not an impact to functionality but it is good habit to use proper variable naming convention
//to improve readability and it can help when debugging things.
// iVariable = integer
// szVariable = string
// fVariable = float

//new szMenu;
new iMenu;

public 
plugin_init() 
{
    
register_pluginPLUGIN VERSION AUTHOR );
    
    
RegisterHamHam_Killed "player" "PostPlayerKilled" );
    
    
iMenu menu_create"\w[\rBB\w]\y Respawn?" "RespawnHandler" );
    
menu_additemiMenu "\wYes" );
    
menu_additemiMenu "\wNo" );
    
menu_setpropiMenu MPROP_NUMBER_COLOR "\r" );
}

public 
PostPlayerKillediVictim iAttacker iShouldGib )
{
    
//** You shouldn't need to check for team here since only a T or CT can be killed..and it's not possible
    //** for a player to change to spectator between the time he is killed and when Ham_Killed post is executed.
    
    //** No need to check that a player is not alive since this is called Ham_Killed post, the player is 
    //** definitely going to be dead.
    
    /*
    iTeam = get_user_team(iVictim);
    if(!is_user_alive(iVictim) && (iTeam == 1 || iTeam == 2))
    {
        menu_display(iVictim, szMenu)
    }*/
    
    
menu_displayiVictim iMenu );
}

public 
RespawnHandlerid iMenuID item )
{    
    
//** You should do the team and alive checking when the user makes a menu selection. This way, if
    //** the menu is still up when a new round starts (and he is spawned naturally), you would not want 
    //** to allow him to re-spawn via the menu. Ideally you should force-close the menu on new round.
    
    //** Use cs_get_user_team() native for cstrike
    
    /*iTeam = get_user_team(id);
    if(!is_user_alive(id) && (iTeam == 1 || iTeam == 2))
    {
        ** No need for a switch for only 1 item. Just have an if statement for menu item 0..
        switch(item)
        {
            case 0: ExecuteHamB(Ham_CS_RoundRespawn, id);
            case 1: return PLUGIN_HANDLED;
        }
    }
    return PLUGIN_HANDLED*/
    
    
if ( item == )
    {
        if ( !
is_user_aliveid ) && ( CS_TEAM_T <= cs_get_user_teamid ) <= CS_TEAM_CT ) )
        {
            
ExecuteHamBHam_CS_RoundRespawn id );
        }
    }

    return 
PLUGIN_HANDLED;



JocAnis 04-04-2020 13:54

Re: Need respawn plugin that asks if u want to respawn
 
@bugsy is `menu_destroy( menu )` necesarry to use when closing the menu? i heard without it the leak of memory is possible to be made, or smth like that

Bugsy 04-04-2020 14:01

Re: Need respawn plugin that asks if u want to respawn
 
In this case, no, since the same menu is being re-used over and over again. If you were creating a fresh menu each time, then I think it would be appropriate.

JocAnis 04-04-2020 15:09

Re: Need respawn plugin that asks if u want to respawn
 
nice to know, thanks

Napoleon_be 04-04-2020 17:49

Re: Need respawn plugin that asks if u want to respawn
 
Thanks for clearing some things up Bugsy.


All times are GMT -4. The time now is 11:57.

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