12.01.2015, 13:30
Hello , i want to make a function to give points to offline player . Following is my offline ban system maybe it gives you any help .
and the following is my giving points to online player .
I mentioned it both so you can get idea/help from it.
PHP код:
CMD:oban(playerid, params[])
{
LoginCheck(playerid);
LevelCheck(playerid, 3);
new
string[150],
name[24],
reason[128],
Query[256],
admin,
ip[20],
DBResult:Result,
ban_hr, ban_min, ban_sec, ban_month, ban_days, ban_years
;
gettime(ban_hr, ban_min, ban_sec);
getdate(ban_years, ban_month, ban_days);
if(sscanf(params, "s[24]s[128]", name, reason)) return SendClientMessage(playerid, COLOR_RED, "<!> Syntax Error: /oban [name in the data] [reason]");
foreach(new i : Player)
{
if(strcmp(pName(i), name, true) == 0)
{
SendClientMessage(playerid, COLOR_RED, "Syntax Error: Player that you are trying to banned is online, /ban instead.");
return 1;
}
}
format(Query, sizeof(Query), "SELECT * FROM `users` WHERE `username` = '%s'", DB_Escape(name));
Result = db_query(Database, Query);
if(db_num_rows(Result))
{
db_get_field_assoc(Result, "admin", Query, 6);
admin = strval(Query);
db_get_field_assoc(Result, "IP", ip, 20);
if(User[playerid][accountAdmin] < admin)
{
SendClientMessage(playerid, COLOR_RED, "Syntax Error: You cannot use this command on high ranking admin.");
#if LOG == true
format(string, sizeof(string), "%s has attempted to offline banned %s but failed for %s", pName(playerid), name, reason);
SaveLog("admin.txt", string);
#endif
return 1;
}
BanAccountEx(name, ip, pName(playerid), reason);
format(string, sizeof(string), "** %s has been offine banned by Administrator %s(%d) (Reason: %s)", name, pName(playerid), playerid, reason);
SendClientMessageToAll(COLOR_GREY, string);
printf(string);
#if LOG == true
SaveLog("banlog.txt", string);
#endif
}
else
{
SendClientMessage(playerid, COLOR_RED, "Syntax Error: There is no such thing players in the server database.");
}
db_free_result(Result);
return 1;
}
PHP код:
CMD:givepp(playerid, params[])
{
LoginCheck(playerid);
if(User[playerid][accountAdmin] >= 3)
{
new string[150], id, amount;
if(sscanf(params, "ui", id, amount)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /givepp [playerid] [amount]");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "» "red"Player not connected.");
if(User[id][accountLogged] == false) return SendClientMessage(playerid, -1, "» "red"Player not logged in.");
format(string, 150, "[PREMIUM POINTS] "red"%s has given %s [%d] Premium Points.", GetName(playerid), GetName(id), amount);
SendAMessage(-1, string);
format(string, 150, ""green"[PREMIUM POINTS] "white"You have received "grey"%d "white"premium points from an "red"admin"white".", amount, User[id][accountPP]+amount);
SendClientMessage(id, -1, string);
format(string, 150, "» You have given {%06x}%s "white"premium points of "grey"%d"white".", GetPlayerColor(id) >>> 8, GetName(id), amount);
SendClientMessage(playerid, -1, string);
format(string, 128, "%s received %d Premium Points from %s.", GetName(id), amount, GetName(playerid));
Log("premium.txt", string);
User[id][accountPP] += amount;
}
else
{
SendClientMessage(playerid, -1, "» "red"You are not authorized to use this command.");
}
return 1;
}