Offline ban system, can't get it to work
#1

Hello.
right now i got this:
PHP код:
COMMAND:osuspend(playeridparams[])
{
    if(!
PlayerInfo[playerid][power]) return SendClientError(playeridCANT_USE_CMD);
    new 
iPlayer[40], eReason128 ];
    if(
sscanf(params,"ss"iPlayereReason))  return SCP(playerid"[Exact_Name] [Reason]");
    new 
query[400],query2[400],string2[128],messaggio[MAX_STRING], string[MAX_STRING],query3[128],temp_ip[32],temp_gpci[100];
    
format(query,sizeof(query),"INSERT INTO suspended (username,reason,bannedby,whendidithappen) VALUES ('%s','%s','%s','%s')",iPlayer,eReason,AnonAdmin(playerid),TimeDate());
    
mysql_function_query(dbhandle,query,false,"","");
    
format(messaggio,sizeof(messaggio),"{FF0000}[Admin]{FF6347} %s has offline-suspended %s. Reason: %s",AnonAdmin(playerid),iPlayer,eReason);
    
format(string,sizeof(string), "4{ OSUSPEND } %s[%d] has offline-suspended %s. Reason: %s %s",AnonAdmin(playerid), playeridiPlayer,  eReasonTimeDate());
    
format(string2,sizeof(string2),"[OSUSPEND] By %s for %s",AnonAdmin(playerid),eReason);
    
    
format(query3,sizeof(query3),"SELECT * FROM user WHERE username ='%s'",iPlayer);
    
mysql_function_query(dbhandle,query3,true,"","");
    
cache_get_field_content(0"regip"temp_ip);
    
format(temp_ip,sizeof(temp_ip),"%s",temp_ip);
    
cache_get_field_content(0"reggpci"temp_gpci);
    
format(temp_gpci,sizeof(temp_gpci),"%s",temp_gpci);
       
SendMessageToAll(COLOR_RED,messaggio);
       
iEcho(string);
       
format(query2,sizeof(query2),"INSERT INTO adminlogs (username,ip,bywho,gpci,wat,whendidithappen) VALUES ('%s','%s','%s','%s','%s','%s')",iPlayer,temp_ip,AnonAdmin(playerid),temp_gpci,string2,TimeDate());
    
mysql_function_query(dbhandle,query2,false,"","");
return 
1;

When type /osuspend Exact_Name, everything gets put in the database nicely, except for the GPCI and the IP.


It just stays blank.
The problem is probably somewhere in this code:
PHP код:
 format(query3,sizeof(query3),"SELECT * FROM user WHERE username ='%s'",iPlayer);
    
mysql_function_query(dbhandle,query3,true,"","");
    
cache_get_field_content(0"regip"temp_ip);
    
format(temp_ip,sizeof(temp_ip),"%s",temp_ip);
    
cache_get_field_content(0"reggpci"temp_gpci);
    
format(temp_gpci,sizeof(temp_gpci),"%s",temp_gpci); 
Can you please help me?
Reply
#2

offline ban with ip? wtf? and please don't use gcpi it is nothing like hardware id, it isn't even a unique id.
Reply
#3

Quote:
Originally Posted by [Bios]Marcel
Посмотреть сообщение
offline ban with ip? wtf? and please don't use gcpi it is nothing like hardware id, it isn't even a unique id.

Yes, so if they login, their ip is banned.
So they don't have to be online to ban them
Reply
#4

PHP код:
format(query3,sizeof(query3),"SELECT * FROM user WHERE username ='%s'",iPlayer); 
    
mysql_function_query(dbhandle,query3,true,"",""); 
    
cache_get_field_content(0"regip"temp_ip); 
    
format(string,sizeof(string),"%s",temp_ip); 
    
cache_get_field_content(0"reggpci"temp_gpci); 
    
format(string2,sizeof(string2),"%s",temp_gpci); 
Why doesn't this work?
the strings stay empty
Reply
#5

mysql_function_query is a threaded function which receives data through a callback rather than halt the server while performing the query.

Код:
mysql_function_query(dbhandle, query3, "OnSuspend", "");

forward OnSuspend();
public OnSuspend()
{
        // get the cache data and do whatever other needed operations
        return true;
}
Reply
#6

Quote:
Originally Posted by Abagail
Посмотреть сообщение
mysql_function_query is a threaded function which receives data through a callback rather than halt the server while performing the query.

Код:
mysql_function_query(dbhandle, query3, "OnSuspend", "");

forward OnSuspend();
public OnSuspend()
{
        // get the cache data and do whatever other needed operations
        return true;
}
Thanks, but in the public i can't use (playerid), so how can i let the public know who did the command?


i got this right now:
PHP код:
forward OnSuspend();
public 
OnSuspend()
{
        
// get the cache data and do whatever other needed operations
  
new num_rows,num_fields;
   
cache_get_data(num_rows,num_fields,dbhandle);
       if(!
PlayerInfo[playerid][power]) return SendClientError(playeridCANT_USE_CMD);
    new 
iPlayer[40], eReason128 ];
    if(
sscanf(params,"ss"iPlayereReason))  return SCP(playerid"[Exact_Name] [Reason]");
    new 
query[400],query2[400],string2[128],messaggio[MAX_STRING], string[MAX_STRING],query3[128],temp_ip[32],temp_gpci[100],string6[32],string5[60];
    
format(query,sizeof(query),"INSERT INTO suspended (username,reason,bannedby,whendidithappen) VALUES ('%s','%s','%s','%s')",iPlayer,eReason,AnonAdmin(playerid),TimeDate());
    
mysql_function_query(dbhandle,query,false,"","");
    
format(messaggio,sizeof(messaggio),"{FF0000}[Admin]{FF6347} %s has offline-suspended %s. Reason: %s",AnonAdmin(playerid),iPlayer,eReason);
    
format(string,sizeof(string), "4{ OSUSPEND } %s[%d] has offline-suspended %s. Reason: %s %s",AnonAdmin(playerid), playeridiPlayer,  eReasonTimeDate());
    
format(string2,sizeof(string2),"[OSUSPEND] By %s for %s",AnonAdmin(playerid),eReason);
    
format(query3,sizeof(query3),"SELECT * FROM user WHERE username ='%s'",iPlayer);
    
mysql_function_query(dbhandle,query3,true,"","");
    
cache_get_field_content(0"regip"temp_ip);
    
format(string6,sizeof(string6),"%s",temp_ip);
    
cache_get_field_content(0"reggpci"temp_gpci);
    
format(string5,sizeof(string5),"%s",temp_gpci);
       
format(query2,sizeof(query2),"INSERT INTO adminlogs (username,bywho,wat,whendidithappen,ip,gpci) VALUES ('%s','%s','%s','%s','%s','%s')",iPlayer,AnonAdmin(playerid),string2,TimeDate(),string6,string5);
    
mysql_function_query(dbhandle,query2,false,"","");
       
SendMessageToAll(COLOR_RED,messaggio);
       
iEcho(string);
        return 
true;

and
PHP код:
COMMAND:osuspend(playeridparams[])
{
    new 
query3[128];
    
format(query3,sizeof(query3),"SELECT * FROM user WHERE username ='%s'",iPlayer);
    
mysql_function_query(dbhandle,query3,true,"OnSuspend","");
    return 
1;

when i compile i get this:
error 017: undefined symbol "playerid"
Reply
#7

You actually can pass data through threaded queries. Refer to the example below.
Код:
mysql_function_query(dbhandle, query3, "OnSuspend", "i", playerid);

forward OnSuspend(playerid);
public OnSuspend(playerid)
{
        // get the cache data and do whatever other needed operations
        return true;
}
Reply
#8

Quote:
Originally Posted by Abagail
Посмотреть сообщение
You actually can pass data through threaded queries. Refer to the example below.
Код:
mysql_function_query(dbhandle, query3, "OnSuspend", "i", playerid);

forward OnSuspend(playerid);
public OnSuspend(playerid)
{
        // get the cache data and do whatever other needed operations
        return true;
}
so far i got this:
PHP код:
COMMAND:osuspend(playeridparams[])
{
 if(!
PlayerInfo[playerid][power]) return SendClientError(playeridCANT_USE_CMD);
    new 
iPlayer[40], eReason128 ];
    if(
sscanf(params,"ss"iPlayereReason))  return SCP(playerid"[Exact_Name] [Reason]");
new 
query3[128];
    
format(query3,sizeof(query3),"SELECT * FROM user WHERE username ='%s'",iPlayer);
    
mysql_function_query(dbhandle,query3,true,"OnSuspend","iss",playerid,eReason,iPlayer);
    return 
1;

PHP код:
forward OnSuspend(playerid,eReason,iPlayer);
public 
OnSuspend(playerid,eReason,iPlayer)
{
        
// get the cache data and do whatever other needed operations
    
new num_rows,num_fields;
    
cache_get_data(num_rows,num_fields,dbhandle);
    new 
query[400],query2[400],string2[128],messaggio[MAX_STRING], string[MAX_STRING],query3[128],temp_ip[32],temp_gpci[100],string6[32],string5[60];
    
format(query,sizeof(query),"INSERT INTO suspended (username,reason,bannedby,whendidithappen) VALUES ('%s','%s','%s','%s')",iPlayer,eReason,AnonAdmin(playerid),TimeDate());
    
mysql_function_query(dbhandle,query,false,"","");
    
format(messaggio,sizeof(messaggio),"{FF0000}[Admin]{FF6347} %s has offline-suspended %s. Reason: %s",AnonAdmin(playerid),iPlayer,eReason);
    
format(string,sizeof(string), "4{ OSUSPEND } %s[%d] has offline-suspended %s. Reason: %s %s",AnonAdmin(playerid), playeridiPlayer,  eReasonTimeDate());
    
format(string2,sizeof(string2),"[OSUSPEND] By %s for %s",AnonAdmin(playerid),eReason);
    
format(query3,sizeof(query3),"SELECT * FROM user WHERE username ='%s'",iPlayer);
    
mysql_function_query(dbhandle,query3,true,"","");
    
cache_get_field_content(0"regip"temp_ip);
    
format(string6,sizeof(string6),"%s",temp_ip);
    
cache_get_field_content(0"reggpci"temp_gpci);
    
format(string5,sizeof(string5),"%s",temp_gpci);
       
format(query2,sizeof(query2),"INSERT INTO adminlogs (username,bywho,wat,whendidithappen,ip,gpci) VALUES ('%s','%s','%s','%s','%s','%s')",iPlayer,AnonAdmin(playerid),string2,TimeDate(),string6,string5);
    
mysql_function_query(dbhandle,query2,false,"","");
       
SendMessageToAll(COLOR_RED,messaggio);
       
iEcho(string);
        return 
true;

It all does the job good, thanks.
Only 1 thing: iPlayer now gets defined as "Ь" according to my database.
Any idea why that is?

same goes for the reason
Reply
#9

Perhaps you should stop using the dumb prefixes. iPlayer makes it look like the variable is an integer while you are passing a string. If a function parameter is supposed to be a string then the parameter must be suffixed with square brackets, i.e.:

PHP код:
public OnSuspend(playeridreason[], name[]) 
Reply
#10

Quote:
Originally Posted by Vince
Посмотреть сообщение
Perhaps you should stop using the dumb prefixes. iPlayer makes it look like the variable is an integer while you are passing a string. If a function parameter is supposed to be a string then the parameter must be suffixed with square brackets, i.e.:

PHP код:
public OnSuspend(playeridreason[], name[]) 
thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)