[Help] Giving Points to offline member
#1

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 .
PHP код:
CMD:oban(playeridparams[])
{
    
LoginCheck(playerid);
    
LevelCheck(playerid3);
    new
        
string[150],
        
name[24],
        
reason[128],
        
Query[256],
        
admin,
        
ip[20],
        
DBResult:Result,
        
ban_hrban_minban_secban_monthban_daysban_years
    
;
    
gettime(ban_hrban_minban_sec);
    
getdate(ban_yearsban_monthban_days);
    if(
sscanf(params"s[24]s[128]"namereason)) return SendClientMessage(playeridCOLOR_RED"<!> Syntax Error: /oban [name in the data] [reason]");
    foreach(new 
Player)
    {
        if(
strcmp(pName(i), nametrue) == 0)
        {
            
SendClientMessage(playeridCOLOR_RED"Syntax Error: Player that you are trying to banned is online, /ban instead.");
            return 
1;
        }
    }
    
format(Querysizeof(Query), "SELECT * FROM `users` WHERE `username` = '%s'"DB_Escape(name));
    
Result db_query(DatabaseQuery);
    if(
db_num_rows(Result))
    {
        
db_get_field_assoc(Result"admin"Query6);
        
admin strval(Query);
        
db_get_field_assoc(Result"IP"ip20);
        if(
User[playerid][accountAdmin] < admin)
        {
            
SendClientMessage(playeridCOLOR_RED"Syntax Error: You cannot use this command on high ranking admin.");
            
#if LOG == true
                
format(stringsizeof(string), "%s has attempted to offline banned %s but failed for %s"pName(playerid), namereason);
                
SaveLog("admin.txt"string);
            
#endif
            
return 1;
        }
        
        
BanAccountEx(nameippName(playerid), reason);
        
format(stringsizeof(string), "** %s has been offine banned by Administrator %s(%d) (Reason: %s)"namepName(playerid), playeridreason);
        
SendClientMessageToAll(COLOR_GREYstring);
        
printf(string);
        
#if LOG == true
            
SaveLog("banlog.txt"string);
        
#endif
    
}
    else
    {
        
SendClientMessage(playeridCOLOR_RED"Syntax Error: There is no such thing players in the server database.");
    }
    
db_free_result(Result);
    return 
1;

and the following is my giving points to online player .
PHP код:
CMD:givepp(playeridparams[])
{
    
LoginCheck(playerid);
    if(
User[playerid][accountAdmin] >= 3)
    {
        new 
string[150], idamount;
        if(
sscanf(params"ui"idamount)) return SendClientMessage(playeridCOLOR_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(string150"[PREMIUM POINTS] "red"%s has given %s [%d] Premium Points."GetName(playerid), GetName(id), amount);
        
SendAMessage(-1string);
        
format(string150""green"[PREMIUM POINTS] "white"You have received "grey"%d "white"premium points from an "red"admin"white"."amountUser[id][accountPP]+amount);
        
SendClientMessage(id, -1string);
        
format(string150"» You have given {%06x}%s "white"premium points of "grey"%d"white"."GetPlayerColor(id) >>> 8GetName(id), amount);
        
SendClientMessage(playerid, -1string);
        
format(string128"%s received %d Premium Points from %s."GetName(id), amountGetName(playerid));
        
Log("premium.txt"string);
        
User[id][accountPP] += amount;
    }
    else
    {
        
SendClientMessage(playerid, -1"» "red"You are not authorized to use this command.");
    }
    return 
1;

I mentioned it both so you can get idea/help from it.
Reply
#2

pawn Код:
new file[256];
format(file, sizeof(file), "users/%s.ini", name);
INI_WriteInt(file, "Points", amount);
INI_Close(file);
Something like this. Just save them like this and load them when connect.
Reply
#3

I am using MYSQL . which have extension .db not .ini
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)