L 11/25/2007 - 17:17:57: [AMXX] Run time error 10: native error (native "set_user_health")
Code:
/*
Repay v1.9 by SentryIII
This plugin rewards health for headshots.
It takes the damage you do to others and uses that factor to get your health reward.
*******************************************************************************
Ported By KingPin( <a href="mailto:[email protected]">[email protected]</a> ). I take no responsibility
for this file in any way. Use at your own risk. No warranties of any kind.
*******************************************************************************
ADMIN COMMANDS
==============
amx_repaypercent - Set Repay Percentage - Usage: amx_repaypercent <number>
say /repaylimit - Toggles Whether It Checks If Your Health Exceeds 100
say /repaysave - Toggles If It Saves Your Health Into Next Round.
say /repayshow - Toggles Whether Players can see how much Health Was rewarded to players for headshots.
USER COMMANDS
=============
say /repay - Shows Repay Plugin Info
say voterepaylimit - Starts A Vote To Enable/Disable Repay's Health Limit Check
say voterepaysave - Starts A Vote To Enable/Disable Repay's Save Health Feature
INSTALLATION
============
1. Compile sma to amx
2. Move repay.amx into addons/amxx/plugins
3. Add a line at the end of addons/amxx/plugins.ini to say:
repay.amx
4. Restart Server OR Change Map
5. Done
*/
#include <amxmodx>
#include <amxmisc>
#include <fun>
new bool:repayLimit
new bool:repaySave
static const VERSION
[] = "1.9"
new healths
[33]
public plugin_init
(){
register_plugin("Repay",
"VERSION",
"SentryIII")
register_cvar("amx_repay",
"25")
register_cvar("amx_repayshow",
"1")
register_cvar("amx_repaysave",
"0")
register_cvar("amx_repaylimit",
"1")
register_clcmd("say /repay",
"show_repay")
register_clcmd("say cheat",
"show_info")
register_clcmd("say hack",
"show_info")
register_clcmd("say voterepaylimit",
"vote_repaylimit",
0,
": Starts A Vote To Enable/Disable Repay's Health Limit Feature")
register_clcmd("say voterepaysave",
"vote_repaysave",
0,
": Starts A Vote To Enable/Disable Repay's Health Save Feature")
register_concmd("say /repaylimit",
"toggle_limit",ADMIN_CFG,
": Toggles Whether It Checks If Your Health Exceeds 100 Before Rewarding")
register_concmd("say /repayshow",
"toggle_repayshow",ADMIN_CFG,
": Toggles Whether Or Not You See How Much Health Is Rewarded")
register_concmd("say /repaysave",
"toggle_repaysave",ADMIN_CFG,
": Toggles If It Saves Your Health Into Next Round")
register_concmd("amx_repaypercent",
"set_repaypercent",ADMIN_CFG,
": Set Repay Percentage - Usage: amx_repaypercent <number>")
register_menucmd(register_menuid("Repaylimit?"),
(1<<
0)|
(1<<
1),
"mvote_count")
register_menucmd(register_menuid("Repaysave?"),
(1<<
0)|
(1<<
1),
"mvote_count")
register_event("DeathMsg",
"hs_kill",
"ade",
"3=1",
"5=0")
register_event("ResetHUD",
"load_health",
"be")
register_logevent("save_health",
2,
"1=Round_End")
return PLUGIN_CONTINUE
}
public load_health
(id
){
if (get_cvar_num("amx_repaysave") == 1){
new health
= healths
[id
]
if (health >
100){
set_user_health
(id,health
)
client_print(id,print_chat,
"* You have %d health because of your previous headshot!",health
)
}
}
return PLUGIN_CONTINUE
}
public save_health
(id
){
if (get_cvar_num("amx_repaysave") == 1){
for(new i
= 1; i <
= get_maxplayers();
++i
)
{
healths
[i
] = get_user_health(i
)
}
}
return PLUGIN_CONTINUE
}
public hs_kill
(id
){
new killer
= read_data(1)
new victim
= read_data(2)
new Killer
[33]
new Victim
[33]
new math, math2
get_user_name(killer, Killer,
32)
get_user_name(victim, Victim,
32)
if (get_user_health(victim
) <
= 100){
math
= floatround(Float:(((100 - get_user_health(victim
)) * (get_cvar_float("amx_repay") / 100)) + get_user_health(killer
)), floatround_method
:floatround_round
)
math2
= floatround(Float:(((100 - get_user_health(victim
)) * (get_cvar_float("amx_repay") / 100))), floatround_method
:floatround_round
)
}
if ((get_user_health(victim
) >
100) && (get_user_health(victim
) <
= 200)){
math
= floatround(Float:(((200 - get_user_health(victim
)) * (get_cvar_float("amx_repay") / 100)) + get_user_health(killer
)), floatround_method
:floatround_round
)
math2
= floatround(Float:(((200 - get_user_health(victim
)) * (get_cvar_float("amx_repay") / 100))), floatround_method
:floatround_round
)
}
if (get_user_health(victim
) >
200){
math
= floatround(Float:(((300 - get_user_health(victim
)) * (get_cvar_float("amx_repay") / 100)) + get_user_health(killer
)), floatround_method
:floatround_round
)
math2
= floatround(Float:(((300 - get_user_health(victim
)) * (get_cvar_float("amx_repay") / 100))), floatround_method
:floatround_round
)
}
if (get_cvar_num("amx_repaylimit") == 0){
if (get_user_team(killer
) != get_user_team(victim
) && get_cvar_num("amx_repay") != 0){
set_hudmessage(255,
255,
255,
-1.0,
-0.75,
2,
0.02,
10.0,
0.01,
0.1,
9)
set_user_health
(killer, math
)
if (get_cvar_num("amx_repayshow") == 0){
show_hudmessage(0,
"%s Was Awarded Health^nFor Killing %s With A Headshot!",Killer,Victim
)
log_message("[REPAY] %s Got %d Health : Killed %s",Killer,math2,Victim
)
}
if (get_cvar_num("amx_repayshow") == 1){
show_hudmessage(0,
"%s Was Awarded %d Health^nFor Killing %s With A Headshot!",Killer,math2,Victim
)
log_message("[REPAY] %s Got %d Health : Killed %s",Killer,math2,Victim
)
}
}
}
if (get_cvar_num("amx_repaylimit") == 1){
if (get_user_health(killer
) >
= 100 && get_cvar_num("amx_repay") != 0){
set_hudmessage(255,
255,
255,
-1.0,
-0.75,
2,
0.02,
10.0,
0.01,
0.1,
9)
show_hudmessage(0,
"%s Got A Headshot On %s!^nNo Health Rewarded, MAX Health",Killer,Victim
)
log_message("[REPAY] %s (MAX HEALTH) : Killed %s",Killer,Victim
)
}
else if (get_user_team(killer
) != get_user_team(victim
) && get_cvar_num("amx_repay") != 0){
set_hudmessage(255,
255,
255,
-1.0,
-0.75,
2,
0.02,
10.0,
0.01,
0.1,
9)
set_user_health
(killer, math
)
if (get_user_health(killer
) >
100){
set_user_health
(killer,
100)
}
if (get_cvar_num("amx_repayshow") == 0){
show_hudmessage(0,
"%s Was Awarded Health^nFor Killing %s With A Headshot!",Killer,Victim
)
log_message("[REPAY] %s Got %d Health : Killed %s",Killer,math2,Victim
)
}
if (get_cvar_num("amx_repayshow") == 1){
if (math >
100){
show_hudmessage(0,
"%s Was Awarded %d Health^nBut Was Limited To Only 100 Health^nFor Killing %s With A Headshot!",Killer,math2,Victim
)
log_message("[REPAY] %s Got %d Health (LIMITED) : Killed %s",Killer,math2,Victim
)
}
if (math <
100){
show_hudmessage(0,
"%s Was Awarded %d Health^nFor Killing %s With A Headshot!",Killer,math2,Victim
)
log_message("[REPAY] %s Got %d Health : Killed %s",Killer,math2,Victim
)
}
}
}
}
return PLUGIN_CONTINUE
}
public show_repay
(){
new percent
= get_cvar_num("amx_repay")
set_hudmessage(255,
255,
255,
-1.0,
0.70,
2,
0.02,
10.0,
0.01,
0.1,
9)
show_hudmessage(0,
"This server is using AMX plugin : Headshot Repay^nRepay Plugin was made by SentryIII.^nCurrent Version: %s^nCurrent Repay Percentage: %d",VERSION,percent
)
return PLUGIN_HANDLED
}
public show_info
(){
set_hudmessage(255,
255,
255,
-1.0,
0.70,
2,
0.02,
10.0,
0.01,
0.1,
9)
show_hudmessage(0,
"Repay: A plugin rewards health for headshots.^nIt takes the damage you do to others and uses that factor to get your health reward.^nConsider that before you accuse anybody of cheating.")
return PLUGIN_HANDLED
}
public set_repaypercent
(id,level,cid
){
if (!cmd_access(id,level,cid,
2))
return PLUGIN_HANDLED
new arg
[4]
read_argv(1,arg,
3)
set_cvar_num("amx_repay",
str_to_num(arg
))
return PLUGIN_HANDLED
}
public toggle_repayshow
(id,level,cid
){
if (!cmd_access(id,level,cid,
2))
return PLUGIN_HANDLED
if (get_cvar_num("amx_repayshow") == 1){
server_cmd("amx_repayshow 0")
set_hudmessage(255,
255,
255,
-1.0,
0.70,
2,
0.02,
10.0,
0.01,
0.1,
9)
show_hudmessage(0,
"Repay^nShow Health OFF")
}
if (get_cvar_num("amx_repayshow") == 0){
server_cmd("amx_repayshow 1")
set_hudmessage(255,
255,
255,
-1.0,
0.70,
2,
0.02,
10.0,
0.01,
0.1,
9)
show_hudmessage(0,
"Repay^nShow Health ON")
}
return PLUGIN_HANDLED
}
public toggle_repaysave
(id,level,cid
){
if (!cmd_access(id,level,cid,
2))
return PLUGIN_HANDLED
if (get_cvar_num("amx_repaysave") == 1){
server_cmd("amx_repaysave 0")
set_hudmessage(255,
255,
255,
-1.0,
0.70,
2,
0.02,
10.0,
0.01,
0.1,
9)
show_hudmessage(0,
"Repay^nSave Health OFF")
}
if (get_cvar_num("amx_repaysave") == 0){
server_cmd("amx_repaysave 1")
set_hudmessage(255,
255,
255,
-1.0,
0.70,
2,
0.02,
10.0,
0.01,
0.1,
9)
show_hudmessage(0,
"Repay^nSave Health ON")
}
return PLUGIN_HANDLED
}
public toggle_limit
(id,level,cid
){
if (!cmd_access(id,level,cid,
2))
return PLUGIN_HANDLED
if (get_cvar_num("amx_repaylimit") == 1){
server_cmd("amx_repaylimit 0")
set_hudmessage(255,
255,
255,
-1.0,
0.70,
2,
0.02,
10.0,
0.01,
0.1,
9)
show_hudmessage(0,
"Repay^nCheck Health OFF")
}
if (get_cvar_num("amx_repaylimit") == 0){
server_cmd("amx_repaylimit 1")
set_hudmessage(255,
255,
255,
-1.0,
0.70,
2,
0.02,
10.0,
0.01,
0.1,
9)
show_hudmessage(0,
"Repay^nCheck Health ON")
}
return PLUGIN_HANDLED
}
new moptions
[2]
new voterepaylimit
[] = "\y[REPAY]Health Limit (100 HP)\w^n^n1. Yes^n2. No"
new voterepaysave
[] = "\y[REPAY]Save Health (Untill Death)\w^n^n1. Yes^n2. No"
public vote_repaylimit
(id
){
new Float:voting
= get_cvar_float("amx_last_voting")
if (voting >
get_gametime()) {
client_print(id,print_chat,
"* There is already one voting...")
return PLUGIN_HANDLED
}
if (voting
&& voting
+ get_cvar_float("amx_vote_delay") >
get_gametime()) {
client_print(id,print_chat,
"* Voting not allowed at this time...")
return PLUGIN_HANDLED
}
new menu_msg
[256]
format(menu_msg,
255,voterepaylimit,repayLimit ?
"No" : "Yes")
new Float:vote_time
= get_cvar_float("amx_vote_time") + 2.0
set_cvar_float("amx_last_voting",
get_gametime() + vote_time
)
show_menu(0,
(1<<
0)|
(1<<
1),menu_msg,
floatround(vote_time
))
set_task(vote_time,
"check_mvotes")
client_print(0,print_chat,
"* Voting has started...")
moptions
[0]=moptions
[1]=0
return PLUGIN_CONTINUE
}
public vote_repaysave
(id
){
new Float:voting
= get_cvar_float("amx_last_voting")
if (voting >
get_gametime()) {
client_print(id,print_chat,
"* There is already one voting...")
return PLUGIN_HANDLED
}
if (voting
&& voting
+ get_cvar_float("amx_vote_delay") >
get_gametime()) {
client_print(id,print_chat,
"* Voting not allowed at this time...")
return PLUGIN_HANDLED
}
new menu_msg
[256]
format(menu_msg,
255,voterepaysave,repaySave ?
"No" : "Yes")
new Float:vote_time
= get_cvar_float("amx_vote_time") + 2.0
set_cvar_float("amx_last_voting",
get_gametime() + vote_time
)
show_menu(0,
(1<<
0)|
(1<<
1),menu_msg,
floatround(vote_time
))
set_task(vote_time,
"check_mvotes2")
client_print(0,print_chat,
"* Voting has started...")
moptions
[0]=moptions
[1]=0
return PLUGIN_CONTINUE
}
public mvote_count
(key
){
++moptions
[key
]
return PLUGIN_HANDLED
}
public check_mvotes
(){
set_hudmessage(255,
255,
255,
-1.0,
-0.75)
if (moptions
[0] > moptions
[1]){
if (get_cvar_num("amx_repaylimit") == 1){
server_cmd("amx_repaylimit 0")
show_hudmessage(0,
"Health Limit^nHas Been Turned OFF")
}
else if (get_cvar_num("amx_repaylimit") == 0){
server_cmd("amx_repaylimit 1")
show_hudmessage(0,
"Health Limit^nHas Been Turned ON")
}
}
else{
if (get_cvar_num("amx_repaylimit") == 0){
server_cmd("amx_repaylimit 1")
show_hudmessage(0,
"Health Limit^nHas Been Turned ON")
}
else if (get_cvar_num("amx_repaylimit") == 1){
server_cmd("amx_repaylimit 0")
show_hudmessage(0,
"Health Limit^nHas Been Turned OFF")
}
}
return PLUGIN_CONTINUE
}
public check_mvotes2
(){
set_hudmessage(255,
255,
255,
-1.0,
-0.75)
if (moptions
[0] > moptions
[1]){
if (get_cvar_num("amx_repaysave") == 1){
server_cmd("amx_repaysave 0")
show_hudmessage(0,
"Health Save^nHas Been Turned OFF")
}
else if (get_cvar_num("amx_repaysave") == 0){
server_cmd("amx_repaysave 1")
show_hudmessage(0,
"Health Save^nHas Been Turned ON")
}
}
else{
if (get_cvar_num("amx_repaysave") == 0){
server_cmd("amx_repaysave 1")
show_hudmessage(0,
"Health Save^nHas Been Turned ON")
}
else if (get_cvar_num("amx_repaysave") == 1){
server_cmd("amx_repaysave 0")
show_hudmessage(0,
"Health Save^nHas Been Turned OFF")
}
}
return PLUGIN_CONTINUE
}