AlliedModders

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

TheDemonIII 05-29-2006 14:03

revive plugin
 
hey. Im trying to make a revive plugin for cs. I got it to revive a player, but in order to do so you have to type their full name (case sensitive) Does anyone know a way to get around that?

here is my plugins code

Code:

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

#define PLUGIN "Revive"
#define VERSION "1.0"
#define AUTHOR "Demon"


public plugin_init() {
        register_plugin(PLUGIN, VERSION, AUTHOR)
        register_concmd("amx_revive","revive_player", ADMIN_KICK, "Revive a player.")
}

public revive_player(id, level, cid)
{
        if (!cmd_access(id, level, cid,2))
        {
                return PLUGIN_HANDLED
        }
        new Player[30]
        new  PlayerIndex
       
        read_argv(1,Player,29)
        PlayerIndex = get_user_index(Player)
        if(!is_user_alive(PlayerIndex))
        {
                spawn(PlayerIndex)
                return(PLUGIN_HANDLED)
        }
       
        return(PLUGIN_HANDLED)
}

[/small]

Hawk552 05-29-2006 14:05

Use cmd_target. Also, instead of spawn, use cs_user_spawn.

TheDemonIII 05-29-2006 14:09

can u explain how to use cmd_target, i just started scripting yesterday so im pretty new to it. also i tried cs_user_spawn, it didn't work

Hawk552 05-29-2006 14:11

cmd_target(id,Player,1)

spawn does not work if you use it only once, so you must be wrong.

TheDemonIII 05-29-2006 14:12

nah spawn works fine, but wat else do i need for the cmd_target, that it?

Hawk552 05-29-2006 14:15

Quote:

Originally Posted by TheDemonIII
nah spawn works fine, but wat else do i need for the cmd_target, that it?

That's it. Just replace get_user_index with that code snippet. The function returns an id if it manages to match.

TheDemonIII 05-29-2006 14:17

is this what you mean? if so it doesnt work, it says that i have immunity (which i do) then says amx_revive isnt a command


Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>

#define PLUGIN "Revive"
#define VERSION "1.0"
#define AUTHOR "Demon"


public plugin_init() {
        register_plugin(PLUGIN, VERSION, AUTHOR)
        register_concmd("amx_revive","revive_player", ADMIN_KICK, "Revive a player.")
}

public revive_player(id, level, cid)
{
        if (!cmd_access(id, level, cid,2))
        {
                return PLUGIN_HANDLED
        }
        new Player[30]
        new  PlayerIndex
        read_argv(1,Player,29)

        PlayerIndex = cmd_target(id, Player)
        if(!is_user_alive(PlayerIndex))
        {
                spawn(PlayerIndex)
                return(PLUGIN_HANDLED)
        }
       
        return(PLUGIN_HANDLED)
}


Hawk552 05-29-2006 14:26

Cleaned up:

Code:
#include <amxmodx> #include <amxmisc> #include <fun> #include <cstrike> public plugin_init() {     register_plugin("Revive","1.0","TheDemonIII")         register_concmd("amx_revive","revive_player", ADMIN_KICK, "Revive a player.") } public revive_player(id, level, cid) {     if (!cmd_access(id, level, cid,2))         return PLUGIN_HANDLED             new szPlayer[33],iPlayer     read_argv(1,szPlayer,32)     iPlayer = cmd_target(id,szPlayer,0)         if(!is_user_alive(iPlayer))         cs_user_spawn(iPlayer)         return(PLUGIN_HANDLED) }

TheDemonIII 05-29-2006 14:29

well it works, thank you so much, i dont really understand why though. the only change i see is that u changed ur variable names and made the string length 33, would that really have a difference?

Hawk552 05-29-2006 14:31

Quote:

Originally Posted by TheDemonIII
well it works, thank you so much, i dont really understand why though. the only change i see is that u changed ur variable names and made the string length 33, would that really have a difference?

cmd_target has parm 3 set at 0, default is 1 which is what you left it at.

Also, I used cs_user_spawn which does work better if you're using CS.


All times are GMT -4. The time now is 16:20.

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