AlliedModders

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

Sonic7145 12-28-2005 23:50

changing health plugin
 
pruned

v3x 12-29-2005 00:06

You need to give Arg2 a specified length. Some other minor fixes. Also, you should use cmd_access instead of:
Code:
  if (!(get_user_flags(id)&ADMIN_KICK)) {     console_print(id,"No access to amx_health - Sorry.")     return PLUGIN_HANDLED   }   if (read_argc() == 0) {     console_print(id,"No user given.")     return PLUGIN_HANDLED   }

Code:
#include <amxmodx> #include <amxmisc> #include <fun> #define PLUGIN "AMX Health" #define VERSION "1.0" #define AUTHOR "Sonic" public plugin_init() {          register_plugin(PLUGIN, VERSION, AUTHOR)      register_concmd("amx_health", "change_health", ADMIN_KICK, "admin changes a users health ")       } public change_health(id){   if (!(get_user_flags(id)&ADMIN_KICK)) {     console_print(id,"No access to amx_health - Sorry.")     return PLUGIN_HANDLED   }   if (read_argc() == 0) {     console_print(id,"No user given.")     return PLUGIN_HANDLED   }   new user[32], uid, Arg2[4];       read_argv(1,user,32)   read_argv(2,Arg2,3)   new hp = str_to_num(Arg2)   uid = find_player("bh",user)   if (uid == 0) {     console_print(id,"Couldn't find user.")     return PLUGIN_HANDLED   }       set_user_health(uid, hp)   console_print(id,"User's health has been set to %i!")   return PLUGIN_HANDLED }

Kensai 12-29-2005 00:07

Code:
#include <amxmodx> #include <amxmisc> #include <fun> public plugin_init() {      register_plugin("AMX Health","1.0","Sonic") //this is easier then your defines      register_concmd("amx_health", "change_health", ADMIN_KICK, "<target> <health> - admin changes a users health ") //Needed args } public change_health(id,level,cid) {     if (!cmd_access(id,level,cid, 3))//Thisautomatically prints a "no access" message     return PLUGIN_HANDLED           new arg[32], arg2[32]     read_argv(1,arg,31)//read_argv reads the arguments or the "target and health"     read_argv(2,arg2,31)         new target=cmd_target(id,arg,4)//4 means they must be alive         if(!target)     {         client_print(id,print_console,"[AMXX] Invalid target!")//if there is no one that matches the target, it prints the message         return PLUGIN_HANDLED     }         set_user_health(target,arg2)//target is the person your setting heatlh, arg2 is the second argument "<health>"     return PLUGIN_HANDLED }

Charr 12-29-2005 12:34

Kensai you need to use
Code:
set_user_health(target,str_to_num(arg2))


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

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