L 09/29/2018 - 18:53:23: [AMXX] Run time error 10: native error (native "get_user_weapon")
PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <fakemeta>
#include <cstrike>
#include <hamsandwich>
#include <nvault>
/*
UPDATES
2.9 - New Logs
2.8 - Fix Logs
2.7 - Set New Command "Set_Credits"
2.6 - Set New Command "Give Credits"
2.5 - Fix Errors
2.4 - Fix Acess Flags
2.3 - Create Function To Easy Save Credits SaveCredits(id);
2.2 - Create Vault
2.1 - Create Multiples Ways To Win Credits
2.0 - Fix Conditions To Give Credits
1.9 - Set HUD To Display Credits
1.8 - Check Credits
1.7 - Create Update Time To Update Chat Credits
1.6 - Set Task
1.5 - Create Variables
1.4 - Recreate All Code
1.3 - Fix Old Code
1.2 - Fail Tries
1.1 - Set Code.
*/
#define PLUGIN "Moedas"
#define VERSION "2.9"
#define AUTHOR "_|Polimpo4|_"
#define STATS_COINS 0
#define UPDATETIME 5.0
new g_coins[33][1];
new vault, wid, hs;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
register_concmd("amx_give_credits", "Give_Credits", ADMIN_IMMUNITY, "Name/@T/@CT/@All -> Amount");
register_concmd("amx_set_credits", "Set_Credits", ADMIN_IMMUNITY, "Name/@T/@CT/@All -> Amount");
set_task( UPDATETIME, "ShowCoinDetails", _, _, _, "b" );
vault = nvault_open("SaveCoins")
}
public fw_PlayerKilled(victim, attacker, shouldgib)
{
if (victim == attacker || !is_user_alive(attacker) )
{
return;
}
new Aname[32], Vname[32];
get_user_name( attacker , Aname , charsmax( Aname ) );
get_user_name( victim , Vname , charsmax( Vname ) );
attacker = get_user_attacker(victim, wid, hs)
if(get_user_weapon(attacker) == CSW_KNIFE && is_user_alive(attacker))
{
g_coins[attacker][STATS_COINS]+=1
//client_print (attacker, print_chat, "You killed %s with a knife", V_name)
//client_print (victim, print_chat, "You were killed by %s with a knife", A_name)
}
else if(hs==HIT_HEAD)
{
g_coins[attacker][STATS_COINS]+=2
//client_print (victim, print_chat, "%s got you a headshoot", A_name)
}
g_coins[attacker][STATS_COINS]++
client_print( attacker, print_center, "Moedas %d", g_coins[attacker]);
}
public ShowCoinDetails()
{
new Players[ 32 ];
new playerCount, i, player;
get_players(Players, playerCount, "ach");
for (i=0; i<playerCount; i++)
{
player = Players[ i ];
new name[ 50 ];
get_user_name( player, name, 49 );
new x_coins = g_coins[player][STATS_COINS]
if(is_user_alive(player))
{
set_hudmessage( 0, 255, 255, 0.02, 0.17, 0, 6.0, UPDATETIME );
show_hudmessage( player, "[MOEDAS : %i]",x_coins);
}
}
}
public Give_Credits(id, level, cid) {
if(!cmd_access(id, level, cid, 2)) {
return PLUGIN_HANDLED;
}
new Players[ 32 ];
new playerCount, i, player;
get_players(Players, playerCount, "ach");
for (i=0; i<playerCount; i++)
{
player = Players[ i ];
}
new arg[23], gplayers[32], num, players, name[32];
get_user_name(id, name, 31);
read_argv(1, arg, 23);
new give_credits[5];
read_argv(2, give_credits, charsmax(give_credits));
new dar_coins = str_to_num(give_credits);
if(equali(arg, "@T")) {
get_players(gplayers, num, "e", "TERRORIST");
for(i = 0; i < num; i++) {
players = gplayers[i];
if(!is_user_connected(players))
continue;
g_coins[player][STATS_COINS] += dar_coins;
SaveCoins(id)
}
new x_coins = g_coins[player][STATS_COINS];
switch(get_cvar_num("amx_show_activity")) {
case 1: ColorChat(0, "^x03ADMIN^x04 give^x03 %i Credits^x04 to all^x03 Ts.", x_coins);
case 2: ColorChat(0, "^x03%s^x04 give^x03 %i Credits^x04 to all^x03 Ts.", name, x_coins);
}
}
else if(equali(arg, "@CT")) {
get_players(gplayers, num, "e", "CT");
for(i = 0; i < num; i++) {
if(!is_user_connected(players))
continue;
g_coins[player][STATS_COINS] += dar_coins;
SaveCoins(id)
}
new x_coins = g_coins[player][STATS_COINS];
switch(get_cvar_num("amx_show_activity")) {
case 1: ColorChat(0, "^x03ADMIN^x04 give^x03 %i Credits^x04 to all^x03 CTs.", x_coins);
case 2: ColorChat(0, "^x03%s^x04 give^x03 %i Credits^x04 to all^x03 CTs.", name, x_coins);
}
}
if(equali(arg, "@All")) {
get_players(gplayers, num, "a");
for(i = 0; i < num; i++) {
if(!is_user_connected(players))
continue;
g_coins[player][STATS_COINS] += dar_coins;
SaveCoins(id)
}
new x_coins = g_coins[player][STATS_COINS];
switch(get_cvar_num("amx_show_activity")) {
case 1: ColorChat(0, "^x03ADMIN^x04 give^x03 %i Credits^x04 to all^x03 Players.", x_coins);
case 2: ColorChat(0, "^x03%s^x04 give^x03 %i Credits^x04 to all^x03 Players.", name, x_coins);
}
}
new playertg = cmd_target(id, arg, 11);
if(!playertg) {
return PLUGIN_HANDLED;
}
g_coins[player][STATS_COINS] += dar_coins;
SaveCoins(id)
new x_coins = g_coins[player][STATS_COINS];
switch(get_cvar_num("amx_show_activity")) {
case 1: ColorChat(player, "^x03ADMIN^x04 give your^x03 %i Credits.", x_coins);
case 2: ColorChat(player, "^x03%s^x04 give your^x03 %i Credits.", name, x_coins);
}
return PLUGIN_HANDLED;
}
public Set_Credits(id, level, cid) {
if(!cmd_access(id, level, cid, 2)) {
return PLUGIN_HANDLED;
}
new Players[ 32 ];
new playerCount, i, player;
get_players(Players, playerCount, "ach");
for (i=0; i<playerCount; i++)
{
player = Players[ i ];
}
new arg[23], gplayers[32], num, players, name[32];
get_user_name(id, name, 31);
read_argv(1, arg, 23);
new give_credits[5];
read_argv(2, give_credits, charsmax(give_credits));
new set_coins = str_to_num(give_credits);
if(equali(arg, "@T")) {
get_players(gplayers, num, "e", "TERRORIST");
for(i = 0; i < num; i++) {
players = gplayers[i];
if(!is_user_connected(players))
continue;
g_coins[player][STATS_COINS] = set_coins;
SaveCoins(id)
}
new x_coins = g_coins[player][STATS_COINS];
switch(get_cvar_num("amx_show_activity")) {
case 1: ColorChat(0, "^x03ADMIN^x04 set to all^x03 Ts^x03 %i Credits.", x_coins);
case 2: ColorChat(0, "^x03%s^x04 set to all^x03 Ts^x03 %i Credits.", name, x_coins);
}
}
else if(equali(arg, "@CT")) {
get_players(gplayers, num, "e", "CT");
for(i = 0; i < num; i++) {
if(!is_user_connected(players))
continue;
g_coins[player][STATS_COINS] = set_coins;
SaveCoins(id)
}
new x_coins = g_coins[player][STATS_COINS];
switch(get_cvar_num("amx_show_activity")) {
case 1: ColorChat(0, "^x03ADMIN^x04 set to all^x03 CTs^x03 %i Credits.", x_coins);
case 2: ColorChat(0, "^x03%s^x04 set to all^x03 CTs^x03 %i Credits.", name, x_coins);
}
}
if(equali(arg, "@All")) {
get_players(gplayers, num, "a");
for(i = 0; i < num; i++) {
if(!is_user_connected(players))
continue;
g_coins[player][STATS_COINS] = set_coins;
SaveCoins(id)
}
new x_coins = g_coins[player][STATS_COINS];
switch(get_cvar_num("amx_show_activity")) {
case 1: ColorChat(0, "^x03ADMIN^x04 set to all^x03 Players^x03 %i Credits.", x_coins);
case 2: ColorChat(0, "^x03%s^x04 set to all^x03 Players^x03 %i Credits.", name, x_coins);
}
}
new playertg = cmd_target(id, arg, 11);
if(!playertg) {
return PLUGIN_HANDLED;
}
g_coins[player][STATS_COINS] = set_coins;
SaveCoins(id)
new x_coins = g_coins[player][STATS_COINS];
switch(get_cvar_num("amx_show_activity")) {
case 1: ColorChat(player, "^x03ADMIN^x04 set your Credits to^x03 %i.", x_coins);
case 2: ColorChat(player, "^x03%s^x04 set your Credits to^x03 %i.", name, x_coins);
}
return PLUGIN_HANDLED;
}
public SaveCoins(id){
new name[32],data[512]
get_user_name(id,name,31)
formatex(data,511,"%d",g_coins[id][STATS_COINS])
nvault_set(vault,name,data)
}
public client_putinserver(id)
{
new name[32],data[512],raw[1][20]
get_user_name(id,name,31)
if(!nvault_get(vault,name,data,511))
return PLUGIN_CONTINUE
parse(data,raw[0],19)
g_coins[id][STATS_COINS]=str_to_num(raw[0])
return PLUGIN_CONTINUE
}
public client_disconnect(id)
{
SaveCoins(id);
}
//####################Color Chat######
stock ColorChat(const id, const input[], any:...) {
new count = 1, players[32];
static msg[191];
vformat(msg, 190, input, 3);
replace_all(msg, 190, "!x04", "^4");
replace_all(msg, 190, "!x01", "^1");
replace_all(msg, 190, "!x03", "^3");
if(id) players[0] = id;
else get_players(players, count, "ch"); {
for(new i = 0; i < count; i++) {
if(is_user_connected(players[i])) {
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}
}
}