Issue with kicking players from an event
#1

Solved.
Reply
#2

PHP Code:
if(!strcmp(params"kick"true))
    {
        if( 
sscanf(params"su"paramsid))
            return 
SendUsageErrorplayerid"/toggle [Kick] [ID]" ); 
PHP Code:
if(!strcmp(params"kick"true))
    {
        if( 
sscanf(params"su"id))
            return 
SendUsageErrorplayerid"/toggle [ID]" ); 
Since you're already checking if param is kick, you have to check the id under the command, i think so, at least.

And where did /toggle come from? isnt it supposed to be /event kick id
Reply
#3

Make a sscanf before the strcmp to check for even more parameters, but make it optional so it doesn't have to be included.

Quote:
Originally Posted by The Great Emmet_
EVERY format specifier (that is, everything except '', {} and p) now has an optional equivalent - this is just their letter capitalised, so for example the old "z" optional string specifier is now "S" (there is still "z" and, for completeness, "Z", but both give warnings). In addition to optional specifiers, there are also now default values:
(https://sampforum.blast.hk/showthread.php?tid=570927)

So simply:
Code:
new subcmd[10], subcmdval[128];
if (sscanf(params, "s[10]S()[128]", subcmd, subcmdval))
{
	//Return something if user doesn't put it anything for "s[10]"!
}

if (strcmp(subcmd, "kick", true))
{
	new targetid;
	if (sscanf(subcmdval, "u", targetid))
	{
		//Return something if user did "/cmd kick" but didn't put any value afterwards!
	}
        // Continue what happens if id was given
}
Reply
#4

Quote:
Originally Posted by Hansrutger
View Post
Make a sscanf before the strcmp to check for even more parameters, but make it optional so it doesn't have to be included.


(https://sampforum.blast.hk/showthread.php?tid=570927)

So simply:
Code:
new subcmd[10], subcmdval[128];
if (sscanf(params, "s[10]S()[128]", subcmd, subcmdval))
{
	//Return something if user doesn't put it anything for "s[10]"!
}

if (strcmp(subcmd, "kick", true))
{
	new targetid;
	if (sscanf(subcmdval, "u", targetid))
	{
		//Return something if user did "/cmd kick" but didn't put any value afterwards!
	}
        // Continue what happens if id was given
}
Hey there, thanks for the reply. I have tried what you have suggested but it still does not seem to work.

Have you got another solution?

Thanks!
Reply
#5

Ehm'... What do errors do you get? If no errors, please show how you ended up coding it.
Reply
#6

I had a similar problem which I posted on the forums aswell, listen up what you gotta do.
You need an option string where you store the option, and then store the rest of the given text back to the params variable, IE:
PHP Code:
new option[10];
sscanf(params"s[10]s[128]"optionparams);
if(!
strcmp(option"kick"true))
{
sscanf(params"u"id);

The string size on the first sscanf is 128 because it is the maximum length of an input text, so params without the options could never ever be higher than the params with the option, logically.
Reply
#7

Solved.
Reply
#8

Quote:
Originally Posted by NeXoR
View Post
I had a similar problem which I posted on the forums aswell, listen up what you gotta do.
You need an option string where you store the option, and then store the rest of the given text back to the params variable, IE:
PHP Code:
new option[10];
sscanf(params"s[10]s[128]"optionparams);
if(!
strcmp(option"kick"true))
{
sscanf(params"u"id);

The string size on the first sscanf is 128 because it is the maximum length of an input text, so params without the options could never ever be higher than the params with the option, logically.
That doesn't work either, sorry.
Reply
#9

PHP Code:
CMD:event(playeridparams[])
{
    if( 
pInfo[playerid][pAdmin] < )
        return 
0;
        
    new 
id;
    
    if (
isnull(params))
        return 
SendUsageErrorplayerid"/event [create/rename/teles/kick/freeze/disarm/weapons/end]" );
    if(!
strcmp(params"kick"true))
    {
            new 
kid;
        if (
sscanf(params"su""kick"kid))
            return 
SendUsageErrorplayerid"/event [kick] [ID]" );
        
        if(
inEvent[kid] == 1)
        {
            
format(strsizeof(str), "[EVENT] {FFFFFF}%s has been kicked from the event"Name[kid], kid);
            
SendClientMessageToAll(COLOR_EVENTstr);
                        
SetPlayerHealth(kid0);
                 
inEvent[kid] = 0;
                
eInfo[eventFrozen] = 0;
                
TogglePlayerControllable(kid1);
        }
        else
                {
             
Error(playerid"This player is not participating in your event");
                }
        
    }
    return 
1;

Reply
#10

Quote:
Originally Posted by Yaa
View Post
PHP Code:
CMD:event(playeridparams[])
{
    if( 
pInfo[playerid][pAdmin] < )
        return 
0;
        
    new 
id;
    
    if (
isnull(params))
        return 
SendUsageErrorplayerid"/event [create/rename/teles/kick/freeze/disarm/weapons/end]" );
    if(!
strcmp(params"kick"true))
    {
            new 
kid;
        if (
sscanf(params"su""kick"kid))
            return 
SendUsageErrorplayerid"/event [kick] [ID]" );
        
        if(
inEvent[kid] == 1)
        {
            
format(strsizeof(str), "[EVENT] {FFFFFF}%s has been kicked from the event"Name[kid], kid);
            
SendClientMessageToAll(COLOR_EVENTstr);
                        
SetPlayerHealth(kid0);
                 
inEvent[kid] = 0;
                
eInfo[eventFrozen] = 0;
                
TogglePlayerControllable(kid1);
        }
        else
                {
             
Error(playerid"This player is not participating in your event");
                }
        
    }
    return 
1;

I actually tried that before, it works and sends the usage errors but it does not execute the code if you fill in all parameters.

Anything else?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)