/mute command little problem.
#1

Hello guys, i've created a mute command with reason parameters but the problem is when i type the reason with numbers it works, but with caracteres ain't working!

Here is my code!

PHP код:
CMD:mute(playeridparams[])
{
    if(
Spawned[playerid] == 0) return SendClientMessage(playerid0xf8f8f8fff,"ERROR: {F00f00}You can't use this command while you are not spawned!");
    new 
ID;
    new 
string[128];
    new 
name[MAX_PLAYER_NAME];
    new 
tname[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    
GetPlayerName(IDtname,sizeof(tname));
    if(
sscanf(params,"ii",ID,params)) return SCM(playerid, -1,"Syntax: {FFFFFF}/mute <id> <reason>");
    if(
PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}You aren't authorized to use this command!");
    if(!
IsPlayerConnected(ID)) return SendClientMessage(playerid0xf8f8f8fff,"ERROR: {FFFFFF}Player is not connected");
    
format(stringsizeof(string),"%s was muted by an administrator Reason: %d",tname,params);
    
SCMTA(-1,string);
    
PlayerInfo[ID][pMute] = 1;
    return 
1;

Reply
#2

Besides other things wrong with this, you're only using integer specifiers when checking parameters. Change "ii" in the sscanf line to "ss". There's also a lot of room for optimization besides that.
Reply
#3

PHP код:
CMD:mute(playeridparams[]) 

    if(
Spawned[playerid] == 0) return SendClientMessage(playerid0xf8f8f8fff,"ERROR: {F00f00}You can't use this command while you are not spawned!"); 
    new 
ID,string[128],name[MAX_PLAYER_NAME],tname[MAX_PLAYER_NAME],reason[64]; 
    
GetPlayerName(playeridnamesizeof(name)); 
    if(
sscanf(params,"us[64]",ID,reason)) return SCM(playerid, -1,"Syntax: {FFFFFF}/mute <id> <reason>"); 
    if(
PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}You aren't authorized to use this command!"); 
    if(!
IsPlayerConnected(ID)) return SendClientMessage(playerid0xf8f8f8fff,"ERROR: {FFFFFF}Player is not connected"); 
    
GetPlayerName(IDtname,sizeof(tname)); 
    
format(stringsizeof(string),"%s was muted by an administrator Reason: %s",tname,reason); 
    
SCMTA(-1,string); 
    
PlayerInfo[ID][pMute] = 1
    return 
1

How to works if that is a string , not numbers?
Reply
#4

Quote:
Originally Posted by Abagail
Посмотреть сообщение
Besides other things wrong with this, you're only using integer specifiers when checking parameters. Change "ii" in the sscanf line to "ss". There's also a lot of room for optimization besides that.
as i know s is for string thingy, and now it isn't detecting whose the player and the reason...

Quote:
Originally Posted by Banditul18
Посмотреть сообщение
PHP код:
CMD:mute(playeridparams[]) 

    if(
Spawned[playerid] == 0) return SendClientMessage(playerid0xf8f8f8fff,"ERROR: {F00f00}You can't use this command while you are not spawned!"); 
    new 
ID,string[128],name[MAX_PLAYER_NAME],tname[MAX_PLAYER_NAME],reason[64]; 
    
GetPlayerName(playeridnamesizeof(name)); 
    if(
sscanf(params,"us[64]",ID,reason)) return SCM(playerid, -1,"Syntax: {FFFFFF}/mute <id> <reason>"); 
    if(
PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid0xf8f8f8fff"ERROR: {FFFFFF}You aren't authorized to use this command!"); 
    if(!
IsPlayerConnected(ID)) return SendClientMessage(playerid0xf8f8f8fff,"ERROR: {FFFFFF}Player is not connected"); 
    
GetPlayerName(IDtname,sizeof(tname)); 
    
format(stringsizeof(string),"%s was muted by an administrator Reason: %s",tname,reason); 
    
SCMTA(-1,string); 
    
PlayerInfo[ID][pMute] = 1
    return 
1

How to works if that is a string , not numbers?
I'm using sscanf version 1, so it'd not work
Reply
#5

Quote:
Originally Posted by RxErT
Посмотреть сообщение
I'm using sscanf version 1, so it'd not work
Use sscanf2 then...
Reply
#6

Quote:
Originally Posted by RxErT
Посмотреть сообщение
as i know s is for string thingy, and now it isn't detecting whose the player and the reason...



I'm using sscanf version 1, so it'd not work
You mean the 'u' specifier won't work? If that's the case then use "is[64]" as the specifier and check if the player is connected. But It's better to update your sscanf.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)