Offline suspension doesn't work
#1

Hello.
I made a command for offline banning (suspension)
But, when i enter the command ingame, it keeps showing UNKNOWN COMMAND.
If i only do /osuspend it shows: [Exact_Name] [Reason]
This is the code:
pawn Код:
COMMAND:osuspend(playerid, params[])
{
    if(!PlayerInfo[playerid][power]) return SendClientError(playerid, CANT_USE_CMD);
    if(strcmp(glob_toban,"NoBodY", true))
    {
        return SendClientError(playerid, "Try again in 1 second!");
    }
    new iPlayer, eReason[ 128 ];
    if( sscanf ( params, "ss", iPlayer, eReason))  return SCP(playerid, "[Exact_Name] [Reason]");
 new name[MAX_PLAYER_NAME],query1337[128];
 GetPlayerName(playerid, name, sizeof(name));
 format(query1337,sizeof(query1337),"SELECT * FROM user WHERE username ='%s'",iPlayer);
 mysql_function_query(dbhandle,query1337,true,"","");
new num_rows, num_fields;
   cache_get_data(num_rows,num_fields,dbhandle);
   if(num_rows==0)
   {
   SendClientError(playerid, "That account doesn't exist!");
   return 1;
   }
   else
 {
    if(!IsPlayerConnected(iPlayer))
    {
    new query[400],query2[400],playerserial[128],string2[128],playerip[32],messaggio[MAX_STRING], string[MAX_STRING];
    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), playerid, iPlayer,  eReason, TimeDate());
    format(string2,sizeof(string2),"[OSUSPEND] By %s for %s",AnonAdmin(playerid),eReason);
    gpci(playerid,playerserial,sizeof(playerserial));
    GetPlayerIp(playerid,playerip,32);
    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,playerip,AnonAdmin(playerid),playerserial,string2,TimeDate());
    mysql_function_query(dbhandle,query2,false,"","");
    //AdminDB(PlayerName(iPlayer), string);
    }
    else
    {
    SendClientError(playerid, "That player is currently online!");
    return 1;
    }
}
return 1;
}
Can someone help me?
Reply
#2

It's probably the sscanf, but there is nothing wrong there, right?
Reply
#3

wtf it works when i use this:
PHP код:
if( sscanf params"ds"iPlayereReason))  return SCP(playerid"[Exact_Name] [Reason]"); 
But, it has to be a string, because otherwise it is emitting "я".

Nobody an idea?
Reply
#4

Try this one:
PHP код:
new iPlayer 128 ], eReason128 ];
if(
sscanf(params"s[128]s[128]"iPlayereReason)) return SCP(playerid"[Exact_Name] [Reason]"); 
Reply
#5

You set a player as a string, but it's the u symbol, not s
Reply
#6

Quote:
Originally Posted by KevinExec
Посмотреть сообщение
You set a player as a string, but it's the u symbol, not s
it's an offline player [User_Name].
So it is a string here, right?
Reply
#7

Quote:
Originally Posted by justjamie
Посмотреть сообщение
it's an offline player [User_Name].
So it is a string here, right?
Ohh yeah, then use the luke49's solution
Reply
#8

Quote:
Originally Posted by luke49
Посмотреть сообщение
Try this one:
PHP код:
new iPlayer 128 ], eReason128 ];
if(
sscanf(params"s[128]s[128]"iPlayereReason)) return SCP(playerid"[Exact_Name] [Reason]"); 
Nope doesn't work.
I get another error now tho.
It shows now "[Exact_Name] [Reason]" even tho i filled in everything
Reply
#9

Welp i fixed it
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],playerserial[128],string2[128],playerip[32],messaggio[MAX_STRING], string[MAX_STRING];
    
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);
    
gpci(playerid,playerserial,sizeof(playerserial));
       
GetPlayerIp(playerid,playerip,32);
       
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,playerip,AnonAdmin(playerid),playerserial,string2,TimeDate());
    
mysql_function_query(dbhandle,query2,false,"","");
return 
1;

The string for iPlayer had to be [40] and in sscanf had to be SS.

thanks for your time
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)