Hello!. A have a system that integrates forum and server. So my idea is to give some bonus if the players are active on forum. I made an plugin that gives money from second round, but sometime it gets errors like this:
[AMXX] Displaying debug trace (plugin "forum_bonus.amxx")
[AMXX] Run time error 4: index out of bounds
[AMXX] [0] forum_bonus.sma::Event_RoundStart (line 39)
And there was some strange, that if I'm on the server, I take the money. But if I leave the server, another player takes the money from my name.
Here is the code:
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <cstrike>
#include <colorchat>
#pragma semicolon 1
forward xen_core(id, MemberID, const Name[], Posts, Likes, const Status[], LastVisit);
enum xen_profile {
activity_visible,
user_id,
username[64],
message_count,
like_count,
custom_title[64],
last_activity
};
new xen_data[24][xen_profile], iMoney, maxplayers;
new Round = 0;
public plugin_init() {
register_plugin("Forum Bonus", "0.1", "faKe");
register_event("TextMsg", "Event_TextMsg", "a", "2=#Game_Commencing");
register_event("HLTV", "Event_RoundStart", "a", "1=0", "2=0");
register_logevent("LogEvent_Restart_Round", 2, "1&Restart_Round_");
maxplayers = get_maxplayers();
}
public Event_TextMsg()
Round = 0;
public LogEvent_Restart_Round()
Round = 0;
public Event_RoundStart()
{
Round++;
if (Round > 1)
for (new id=1;id<=maxplayers;id++)
if(is_user_connected(id) && is_user_alive(id))
{
if(xen_data[id][activity_visible])
set_task(0.5,"give_bonus",id );
else
client_print_color(id, 0, "^4[Forum Bonus] ^3Want ^4Bonus? ^3Register on our forum!");
}
return PLUGIN_CONTINUE;
}
public give_bonus(id)
{
iMoney = 150;
iMoney += xen_data[id][like_count]*2;
iMoney += xen_data[id][message_count]*2;
if(xen_data[id][last_activity] + 86400 > get_systime())
iMoney += 150;
cs_set_user_money(id, min(cs_get_user_money(id) + iMoney, 16000));
client_print_color(id, 0, "^4[Forum Bonus] ^3Hello ^4%s! ^3You got ^4%d$ ^3for your activity on forum!", xen_data[id][username], iMoney);
}
public xen_core(id, MemberID, const Name[], Posts, Likes, const Status[], LastVisit)
{
if(is_user_connected(id) && MemberID != 0)
{
xen_data[id][activity_visible] = true;
xen_data[id][user_id] = MemberID;
xen_data[id][message_count] = Posts;
xen_data[id][like_count] = Likes;
copy(xen_data[id][custom_title], 63, Status);
xen_data[id][last_activity] = LastVisit;
copy(xen_data[id][username], 63, Name);
}
}
If someone could help me, I will be very glad. Thanks!