AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Respawn (https://forums.alliedmods.net/showthread.php?t=75482)

xPaw 08-06-2008 11:17

Respawn
 
give code pls for respawn, i need it for my hns shop

zwfgdlc 08-06-2008 13:58

Re: Respawn
 
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 }

XxAvalanchexX 08-06-2008 14:08

Re: Respawn
 
It's best now to use Ham Sandwich.

Code:
ExecuteHam(Ham_CS_RoundRespawn,id);

Nur56 08-08-2008 12:05

Re: Respawn
 
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!

Exolent[jNr] 08-08-2008 13:29

Re: Respawn
 
Quote:

Originally Posted by Nur56 (Post 666500)
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 (Post 665563)
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.

Nur56 08-08-2008 13:51

Re: Respawn
 
Quote:

Originally Posted by X-olent (Post 666535)
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 :P

xPaw 08-08-2008 16:19

Re: Respawn
 
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



danielkza 08-08-2008 16:31

Re: Respawn
 
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).

XxAvalanchexX 08-08-2008 20:19

Re: Respawn
 
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!"); }

danielkza 08-09-2008 12:02

Re: Respawn
 
Quote:

Originally Posted by XxAvalanchexX (Post 666722)
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.


All times are GMT -4. The time now is 05:30.

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