Making a command with 3 parameters -
ax1 - 04.01.2017
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;
}
Re: Making a command with 3 parameters -
Konstantinos - 04.01.2017
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
Re: Making a command with 3 parameters -
ax1 - 04.01.2017
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
Re: Making a command with 3 parameters -
BiosMarcel - 04.01.2017
"uis[25]"
You forgot the specifier for your integer variable "hours"
Re: Making a command with 3 parameters -
Yaa - 04.01.2017
PHP код:
CMD:tempban(playerid, params[])
{
new bannedid, reason[25], hours;
if(sscanf(params, "uis[25]", bannedid, reason,hours)) return SendClientMessage(playerid, RED, "/tempban [player] [reason] [time]");
return 1;
}
Re: Making a command with 3 parameters -
StrikerZ - 04.01.2017
Quote:
Originally Posted by Yaa
PHP код:
CMD:tempban(playerid, params[])
{
new bannedid, reason[25], hours;
if(sscanf(params, "uis[25]", bannedid, reason,hours)) return SendClientMessage(playerid, RED, "/tempban [player] [reason] [time]");
return 1;
}
|
Really?
PHP код:
CMD:tempban(playerid, params[])
{
new bannedid, reason[25], hours;
if(sscanf(params, "us[25]i", bannedid, reason,hours)) return SendClientMessage(playerid, RED, "/tempban [player] [reason] [time]");
return 1;
}
It's like this ^^
Re: Making a command with 3 parameters -
ax1 - 04.01.2017
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;
}
Re: Making a command with 3 parameters -
Yaa - 04.01.2017
PHP код:
CMD:tempban(playerid, params[])
{
new bannedid, reason[25], hours;
if(sscanf(params, "uis[25]", bannedid, hours, reason)) return SendClientMessage(playerid, RED, "/tempban [player] [time] [reason]");
return 1;
}
reason it's last params
@Sunehildeep didn't notice it :P also it's "usi[25]"
Re: Making a command with 3 parameters -
ax1 - 04.01.2017
Quote:
Originally Posted by Yaa
PHP код:
CMD:tempban(playerid, params[])
{
new bannedid, reason[25], hours;
if(sscanf(params, "uis[25]", bannedid, hours, reason)) return SendClientMessage(playerid, RED, "/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
Re: Making a command with 3 parameters -
Yaa - 04.01.2017
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 ?