Raised This Month: $ Target: $400
 0% 

Respawn


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 08-06-2008 , 11:17   Respawn
Reply With Quote #1

give code pls for respawn, i need it for my hns shop
__________________
xPaw is offline
zwfgdlc
Senior Member
Join Date: May 2006
Old 08-06-2008 , 13:58   Re: Respawn
Reply With Quote #2

Code:
#include <amxmodx> #include <amxmisc> #include <fakemeta> #define PLUGIN_NAME "ResPawn_Test" #define PLUGIN_VERSION  "1.0" #define PLUGIN_AUTHOR   "zwfgdlc" #define fm_create_entity(%1) engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, %1)) public plugin_init() {     register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);     register_clcmd("amx_respawn","respawn"); } public respawn(id) {     if(is_user_alive(id)) return ;         dllfunc(DLLFunc_Spawn,id);     set_task(0.5,"playerspawn",id); } public playerspawn(id) {     if(!is_user_connected(id)) return ;     dllfunc(DLLFunc_Spawn,id);         new team=get_user_team(id);     fm_give_item(id,"weapon_knife");     switch(team)     {         case 1:fm_give_item(id,"weapon_glock18");         case 2:fm_give_item(id,"weapon_usp");     }                 } stock fm_give_item(index, const item[]) {     if (!equal(item, "weapon_", 7) && !equal(item, "ammo_", 5) && !equal(item, "item_", 5) && !equal(item, "tf_weapon_", 10))         return 0     new ent = fm_create_entity(item)     if (!pev_valid(ent))         return 0     new Float:origin[3]     pev(index, pev_origin, origin)     set_pev(ent, pev_origin, origin)     set_pev(ent, pev_spawnflags, pev(ent, pev_spawnflags) | SF_NORESPAWN)     dllfunc(DLLFunc_Spawn, ent)     new save = pev(ent, pev_solid)     dllfunc(DLLFunc_Touch, ent, index)     if (pev(ent, pev_solid) != save)         return ent     engfunc(EngFunc_RemoveEntity, ent)     return -1 }
zwfgdlc is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 08-06-2008 , 14:08   Re: Respawn
Reply With Quote #3

It's best now to use Ham Sandwich.

Code:
ExecuteHam(Ham_CS_RoundRespawn,id);
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Nur56
Member
Join Date: Apr 2007
Old 08-08-2008 , 12:05   Re: Respawn
Reply With Quote #4

or(funny, i just made a respawn command today)

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fun>
#define PLUGIN "respawn"
#define VERSION "1.0"
#define AUTHOR "T-Bag"


public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_concmd("amx_respawn","cmd_respawn",ADMIN_BAN,"respawn,hi")
}

public 
cmd_respawn(id,level,cid)
{
    if(!
cmd_access(id,level,cid,2))
    return 
PLUGIN_HANDLED;
    
    new 
targetplayer[32]
    
    
read_argv(1,targetplayer,31)
    new 
player cmd_target(1,targetplayer,31)
    
    if(!
player)
    return 
PLUGIN_HANDLED;
    
    
    new 
playername[32]
    
get_user_name(player,playername,31)
    new 
admin[32]
    
get_user_name(1,admin,31)
    
spawn(player)
    
spawn(player)
    
    
client_print(0,print_chat,"%s Was Respawned by %s!",playername,admin)
    return 
PLUGIN_HANDLED

Important lines: 31-36


Change it to your liking, have fun yo.

NOTE: use spawn() 2 times if your respawning a player because there's a bug in CS/HL, to avoid it use it 2 times!
Nur56 is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 08-08-2008 , 13:29   Re: Respawn
Reply With Quote #5

Quote:
Originally Posted by Nur56 View Post
NOTE: use spawn() 2 times if your respawning a player because there's a bug in CS/HL, to avoid it use it 2 times!
That's not true if you use this:
Quote:
Originally Posted by XxAvalanchexX View Post
It's best now to use Ham Sandwich.

Code:
ExecuteHam(Ham_CS_RoundRespawn,id);
Like he said, its the BEST WAY to respawn a player.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Nur56
Member
Join Date: Apr 2007
Old 08-08-2008 , 13:51   Re: Respawn
Reply With Quote #6

Quote:
Originally Posted by X-olent View Post
That's not true if you use this:


Like he said, its the BEST WAY to respawn a player.

well, your an AMXX plugin approver, so you would know best
Nur56 is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 08-08-2008 , 16:19   Re: Respawn
Reply With Quote #7

tested, works fine ;)
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>

public plugin_init()
{
    
register_plugin("Revive","1.1","xPaw")

    
register_clcmd("amx_revive","cmd_revive",ADMIN_BAN,"<nick | @all>")
}

public 
cmd_revive(id,level,cid)
{
    if(!
cmd_access(id,level,cid,2))
    {
        return 
PLUGIN_HANDLED
    
}

    new 
arg1[32], aName[32], pName[32];
    
read_argv(1,arg1,31)
    
get_user_name(id,aName,31)

    if(
equal(arg1,"@all"))
    {
        
client_print(0,print_chat,"ADMIN %s: Revived everyone.",aName)

        new 
players[32], num
        get_players
(players,num,"gh")
        for(new 
i=0;i<num;i++)
        {
            
ExecuteHam(Ham_CS_RoundRespawn,players[i]);
        }
        
console_print(id,"[AMXX] Revived everyone")
        
log_amx("%s Revived everyone",aName)
    }
    else
    {
        new 
target cmd_target(id,arg1,3)
        if(!
target)
        {
            return 
PLUGIN_HANDLED
        
}

        
get_user_name(target,pName,31)
        
client_print(0,print_chat,"ADMIN %s: Revived %s.",aName,pName)

        
console_print(id,"[AMXX] Revived %s",pName)
        
log_amx("%s Revived %s",aName,pName)
        
ExecuteHam(Ham_CS_RoundRespawn,target);
    }
    return 
PLUGIN_HANDLED

__________________
xPaw is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 08-08-2008 , 16:31   Re: Respawn
Reply With Quote #8

Just change ExecuteHam to ExecuteHamB otherwise other plugins will not be able to detect the respawn (at least using hamsandwich, what is what most people SHOULD be doing now).
danielkza is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 08-08-2008 , 20:19   Re: Respawn
Reply With Quote #9

danielkza: That's what I thought at first. But, it seems the best way to hook player spawn is actually Ham_Spawn instead of Ham_CS_RoundRespawn. The former is called every time, even when you join in the middle of the round and spawn or when you survive the round. The latter gets called most of the time, but not all of the time.

It's still best to use Ham_CS_RoundRespawn to actually respawn a player, though. And when you call that, then it calls Ham_Spawn which can be hooked. So for example, this works:

Code:
#include <amxmodx> #include <hamsandwich> public plugin_init() {     register_clcmd("say spawn","spawn");     RegisterHam(Ham_Spawn,"player","spawned"); } public spawn(id) {     ExecuteHam(Ham_CS_RoundRespawn,id); } public spawned(id) {     client_print(id,print_chat,"* Spawned!"); }
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 08-09-2008 , 12:02   Re: Respawn
Reply With Quote #10

Quote:
Originally Posted by XxAvalanchexX View Post
danielkza: That's what I thought at first. But, it seems the best way to hook player spawn is actually Ham_Spawn instead of Ham_CS_RoundRespawn. The former is called every time, even when you join in the middle of the round and spawn or when you survive the round. The latter gets called most of the time, but not all of the time.

It's still best to use Ham_CS_RoundRespawn to actually respawn a player, though. And when you call that, then it calls Ham_Spawn which can be hooked. So for example, this works:

Code:
#include <amxmodx> #include <hamsandwich> public plugin_init() { &nbsp;&nbsp;&nbsp;&nbsp;register_clcmd("say spawn","spawn"); &nbsp;&nbsp;&nbsp;&nbsp;RegisterHam(Ham_Spawn,"player","spawned"); } public spawn(id) { &nbsp;&nbsp;&nbsp;&nbsp;ExecuteHam(Ham_CS_RoundRespawn,id); } public spawned(id) { &nbsp;&nbsp;&nbsp;&nbsp;client_print(id,print_chat,"* Spawned!"); }
I didn't know that,but I've been using Ham_Spawn for hooking anyway. But we never know what other scripters will do, but it's better be safe. I think as ExecuteHamB as a default, and ExecuteHam is only to avoid infinite loops. But someone may no want to execute the hooks,but i never needed to do it.
danielkza 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 05:30.


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