SA-MP Forums Archive
Issue with kicking players from an event - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Issue with kicking players from an event (/showthread.php?tid=624087)



Issue with kicking players from an event - FunnyBear - 10.12.2016

Solved.


Re: Issue with kicking players from an event - iLearner - 10.12.2016

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


Re: Issue with kicking players from an event - Hansrutger - 10.12.2016

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
}



Re: Issue with kicking players from an event - FunnyBear - 10.12.2016

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!


Re: Issue with kicking players from an event - Hansrutger - 10.12.2016

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


Re: Issue with kicking players from an event - NeXoR - 10.12.2016

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.


Re: Issue with kicking players from an event - FunnyBear - 10.12.2016

Solved.


Re: Issue with kicking players from an event - FunnyBear - 10.12.2016

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.


Re: Issue with kicking players from an event - Yaa - 10.12.2016

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;




Re: Issue with kicking players from an event - FunnyBear - 10.12.2016

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?