Raised This Month: $ Target: $400
 0% 

revive plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TheDemonIII
Junior Member
Join Date: Aug 2005
Old 05-29-2006 , 14:03   revive plugin
Reply With Quote #1

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]
TheDemonIII is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 05-29-2006 , 14:05  
Reply With Quote #2

Use cmd_target. Also, instead of spawn, use cs_user_spawn.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
TheDemonIII
Junior Member
Join Date: Aug 2005
Old 05-29-2006 , 14:09  
Reply With Quote #3

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
TheDemonIII is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 05-29-2006 , 14:11  
Reply With Quote #4

cmd_target(id,Player,1)

spawn does not work if you use it only once, so you must be wrong.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
TheDemonIII
Junior Member
Join Date: Aug 2005
Old 05-29-2006 , 14:12  
Reply With Quote #5

nah spawn works fine, but wat else do i need for the cmd_target, that it?
TheDemonIII is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 05-29-2006 , 14:15  
Reply With Quote #6

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.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
TheDemonIII
Junior Member
Join Date: Aug 2005
Old 05-29-2006 , 14:17  
Reply With Quote #7

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)
}
TheDemonIII is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 05-29-2006 , 14:26  
Reply With Quote #8

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) }
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
TheDemonIII
Junior Member
Join Date: Aug 2005
Old 05-29-2006 , 14:29  
Reply With Quote #9

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?
TheDemonIII is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 05-29-2006 , 14:31  
Reply With Quote #10

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.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
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 16:20.


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