can anyone help me with this code? i can't code pawn but i have the skillz to bug fix it cuz i'm a programmer og another language.
Code:
#include <amxmodx>
#include <dbi>
// SQL RELATED VARIABLES
new Sql:dbc
new Result:result
#define MAXIUMSTR 1023
new Float:emptyFloat = 0.0
new Float:returnMoney[33] = 0.0
new Float:returnKills[33] = 0.0
new Float:returnDeath[33] = 0.0
// ********************* CHANGABLED BELOW **********************
new sqlHost[32] = ""
new sqlUser[32] = ""
new sqlPass[32] = ""
new sqlDB[32] = "Exceed"
new sqlTable[32] = "users"
new sqlAuthid[32] = "authid"
new sqlValue[32] = "xmoney"
new sqlkill[32] = "kills"
new sqldeath[32] = "death"
new sqladmin[32] = "admin"
new Float:cashGain = 0.98
new Float:cashLoss = 1.00
new cashKickReasons[3][] =
{
"", // Placeholder
"You are not registed, join #onedaycup @ Qnet and /Q Exceed to join up for the beta test or see www.ppk.hotserv.dk",
"You ran out of money, in the test you just have to join #onedaycup and /Q Exceed to get more money or see www.ppk.hotserv.dk"
}
// Value to control showing of messages
new bool:show_cash_msg = true
// Value to control showing of HUD
new bool:show_cash_hud = true
// ********************* CHANGABLED ABOVE **********************
public plugin_init() {
register_plugin("Money Plugin","1.0","AssKicR")
register_event("DeathMsg","Event_DeathMsg","a")
register_event("ResetHUD","Event_ResetHUD", "be")
set_task(1.0,"sql_init")
if (show_cash_hud)
set_task(2.0,"HudUpdate",0,"",0,"b") //ACTIVEHUD - SALARY - DOTIME
}
// Initializing the MySQL database sc delete mysql
public client_authorized(id) {
user_money(id,"x",emptyFloat)
}
public sql_init() {
new error[32]
dbc = dbi_connect(sqlHost,sqlUser,sqlPass,sqlDB,error,32)
if (dbc == SQL_FAILED)
server_print("[AMXX] Could Not Connect To SQL Database [Error=%s]^n",error)
else
server_print("[AMXX] Connected To SQL, Have A Nice Day!^n")
}
public Event_ResetHUD(id) {
user_money(id,"x",emptyFloat)
client_print(id,print_chat,"[AMXX] You have %.2f",returnMoney[id])
return PLUGIN_HANDLED
}
public Event_DeathMsg()
{
new killer = read_data(1)
new victim = read_data(2)
if (is_user_connected(killer) && killer!=victim) // Check if user is connected and make sure he was killed by different person
{
new victimname[33]
get_user_name(victim,victimname,32)
if (get_cvar_num("csdm_active")==0) // CSDM is OFF
{
if(get_user_team(killer)==get_user_team(victim))
{ // SAME TEAM - TEAMKILL
if (show_cash_msg)
client_print(killer,print_chat,"[AMXX] You lost $%.2f for killing your team mate %s",cashGain,victimname);
user_money(killer,"-",cashLoss);
}
else
{ // DIFFERENT TEAMS
if (show_cash_msg)
client_print(killer,print_chat,"[AMXX] You got $%.2f for killing %s",cashGain,victimname);
if (show_cash_msg)
client_print(victim,print_chat,"[AMXX] You lost $%.2f for dying",cashLoss);
user_money(killer,"+",cashGain);
user_money(victim,"-",cashLoss);
}
}
else
{ // CSDM is ON
if (show_cash_msg)
client_print(killer,print_chat,"[AMXX] You got $%.2f for killing %s",cashGain,victimname)
if (show_cash_msg)
client_print(victim,print_chat,"[AMXX] You lost $%.2f for dying",cashLoss)
user_money(killer,"+",cashGain)
user_money(victim,"-",cashLoss)
}
}
return PLUGIN_HANDLED
}
user_kick(id,reasonid) { // Function that kicks a player when he isn`t registered or has too little cash
new userid = get_user_userid(id)
server_cmd("kick #%d ^"%s^"",userid,cashKickReasons[reasonid])
return 1
}
user_money(id,func[],Float:changeMoney) {
new userauth[32],userMoney[32], query[MAXIUMSTR+1]
get_user_authid(id,userauth,31)
format(query,MAXIUMSTR,"SELECT %s FROM %s WHERE %s='%s'",sqlValue,sqlTable,sqlAuthid,userauth)
result = dbi_query(dbc,query)
if(dbi_nextrow(result) > 0) // Does User Exist in DataBase
{
// YES HE DOES
dbi_field(result,1,userMoney,MAXIUMSTR-1)
dbi_free_result(result)
if(equali(func,"-"))
{
new Float:newdeath = floatstr(userdeath)+1
new Float:newMoney = floatstr(userMoney)-changeMoney
if (newMoney<=0.99)
{
newMoney=0.0
// user_kick(id,2)
}
format(query,MAXIUMSTR-1,"UPDATE %s SET %s='%.2f' WHERE %s='%s'",sqlTable,sqlValue,newMoney,sqlAuthid,userauth)
dbi_query(dbc,query)
return 1
}
if(equali(func,"+"))
{
new Float:newKills = floatstr(userkills)+1
new Float:newMoney = floatstr(userMoney)+changeMoney
format(query,MAXIUMSTR-1,"UPDATE %s SET %s='%.2f' WHERE %s='%s'",sqlTable,sqlValue,newMoney,sqlAuthid,userauth)
dbi_query(dbc,query)
return 1
}
if(equali(func,"="))
{
new Float:newMoney = changeMoney
new Float:newKills = changeKills
new Float:newdeath = changeDeath
format(query,MAXIUMSTR-1,"UPDATE %s SET %s='%.2f' WHERE %s='%s'",sqlTable,sqlValue,newMoney,sqlAuthid,userauth)
dbi_query(dbc,query)
return 1
}
if(equali(func,"x"))
{
returnMoney[id] = floatstr(userMoney)
if (returnMoney[id]<=emptyFloat)
{
returnMoney[id]=emptyFloat
// user_kick(id,2)
}
return 1
}
}else{
// NO HE DOES'T
// user_kick(id,1)
}
return 1
}
public HudUpdate() {
for(new id=0;id < 33;id++) {
if (is_user_connected(id))
{
user_money(id,"x",emptyFloat)
set_hudmessage(0,255,0,-1.9,0.55,0,0.0,99.9,0.0,0.0,1)
show_hudmessage( id, " Balance: $%.2f",returnMoney[id])
user_kills(id,"x",emptyFloat)
set_hudmessage(0,255,0,-1.9,0.55,0,0.0,99.9,0.0,0.0,1)
show_hudmessage( id, " kills: $%.2f",returnKills[id])
user_death(id,"x",emptyFloat)
set_hudmessage(0,255,0,-1.9,0.55,0,0.0,99.9,0.0,0.0,1)
show_hudmessage( id, " death: $%.2f",returnDeath[id])
}
}
}
i know there mis alot of code in it and there is faults, but i made them so you can see what i need it do more than it does now. the thing it does is to track kills and death.
when you get killed you loss 1 x$ and when you kill one you get $0.98, that works thx to AssKicR and my debygging :p
now i need it to tell the plugin if your an admin, if you are admin will be set to 1 in the db else it will be 0.
it allso need to take the death and kill count from the db and then everytime you die and the same for kills.
at last it need it to be shown under the ballance: (it works) as ye kan see kills and death(i just added them so you can see what i want).
i think it's what i need for now. if you will make this i can recode it by my self, i just need a visual of how to do it :s
[i to the new sqlHost[32] = "", new sqlUser[32] = "" and new sqlPass[32] = "" data out for safety reasons ;)