Making a command with 3 parameters
#1

Im trying to make temporary ban command. It has 3 parameters : player name, reason and hours. I'm not sure how code should look like to check if all these parameters exist, I tried this, but it doesnt work :

Код:
CMD:tempban(playerid, params[])
{
new bannedid, reason[25], hours;
if(sscanf(params, "us[25]", bannedid, reason,hours)) return SendClientMessage(playerid, RED, "/tempban [player] [reason] [time]");
return 1;
}
Reply
#2

Strings parameters always have to be last otherwise it will split by the first space it will find (single words).

The specifier for integer is i
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Strings parameters always have to be last otherwise it will split by the first space it will find (single words).

The specifier for integer is i
Код:
if(sscanf(params, "us[25]", bannedid,hours,reason)) return SendClientMessage(playerid, RED, "/tempban [player] [reason] [time]");
I changed it to this but it still doesnt seem to work
Reply
#4

"uis[25]"

You forgot the specifier for your integer variable "hours"
Reply
#5

PHP код:
CMD:tempban(playeridparams[])
{
     new 
bannedidreason[25], hours;
     if(
sscanf(params"uis[25]"bannedidreason,hours)) return SendClientMessage(playeridRED"/tempban [player] [reason] [time]");
     return 
1;

Reply
#6

Quote:
Originally Posted by Yaa
Посмотреть сообщение
PHP код:
CMD:tempban(playeridparams[])
{
     new 
bannedidreason[25], hours;
     if(
sscanf(params"uis[25]"bannedidreason,hours)) return SendClientMessage(playeridRED"/tempban [player] [reason] [time]");
     return 
1;

Really?
PHP код:
CMD:tempban(playeridparams[]) 

     new 
bannedidreason[25], hours
     if(
sscanf(params"us[25]i"bannedidreason,hours)) return SendClientMessage(playeridRED"/tempban [player] [reason] [time]"); 
     return 
1

It's like this ^^
Reply
#7

I dont know why but it still doesnt work

CMD:tempbanban(playerid, params[])
{
new bannedid, reason[25], hours;
if(sscanf(params, "uis[25]", bannedid, hours, reason)) return SendClientMessage(playerid, RED, "/tempban [player] [reason] [time]");

return 1;
}
Reply
#8

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

     new 
bannedidreason[25], hours
     if(
sscanf(params"uis[25]"bannedidhoursreason)) return SendClientMessage(playeridRED"/tempban [player] [time] [reason]"); 
     return 
1

reason it's last params

@Sunehildeep didn't notice it :P also it's "usi[25]"
Reply
#9

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

     new 
bannedidreason[25], hours
     if(
sscanf(params"uis[25]"bannedidhoursreason)) return SendClientMessage(playeridRED"/tempban [player] [time] [reason]"); 
     return 
1

reason it's last params

@Sunehildeep didn't notice it :P also it's "usi[25]"
It still doesnt work. When I type for example /tempban name 4 cheating i still get /tempban [player] [time] [reason] message
Reply
#10

Quote:
Originally Posted by ax1
Посмотреть сообщение
It still doesnt work. When I type for example /tempban name 4 cheating i still get /tempban [player] [time] [reason] message
show us rest of code ?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)