SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 10/12/2016, 05:30 PM   #1
FunnyBear
Gangsta
 
Join Date: Mar 2013
Posts: 510
Reputation: 15
Default Issue with kicking players from an event

Solved.

Last edited by FunnyBear; 07/01/2017 at 11:27 PM.
FunnyBear is offline   Reply With Quote
Old 10/12/2016, 06:33 PM   #2
iLearner
Guest
 
Posts: n/a
Default Re: Issue with kicking players from an event

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 With Quote
Old 10/12/2016, 07:28 PM   #3
Hansrutger
Gangsta
 
Hansrutger's Avatar
 
Join Date: May 2011
Location: Sweden
Posts: 760
Reputation: 161
Default Re: Issue with kicking players from an event

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:
(http://forum.sa-mp.com/showthread.php?t=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
}
__________________


Hansrutger is offline   Reply With Quote
Old 10/12/2016, 08:32 PM   #4
FunnyBear
Gangsta
 
Join Date: Mar 2013
Posts: 510
Reputation: 15
Default Re: Issue with kicking players from an event

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.


(http://forum.sa-mp.com/showthread.php?t=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!
FunnyBear is offline   Reply With Quote
Old 10/12/2016, 09:01 PM   #5
Hansrutger
Gangsta
 
Hansrutger's Avatar
 
Join Date: May 2011
Location: Sweden
Posts: 760
Reputation: 161
Default Re: Issue with kicking players from an event

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


Hansrutger is offline   Reply With Quote
Old 10/12/2016, 09:08 PM   #6
NeXoR
Gangsta
 
Join Date: Jun 2013
Posts: 577
Reputation: 20
Default Re: Issue with kicking players from an event

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.
__________________
My Releases
[FilterScript] NexAdmin Administration FS [MySQL] [SSCANF] [ZCMD]
[FilterScript] NexBank - Advanced Money System [ATMs] [Anti-Money Hack] [MySQL] [ZCMD]


Currently working on:
[GameMode] Military VS Terrorists
NeXoR is offline   Reply With Quote
Old 10/12/2016, 09:12 PM   #7
FunnyBear
Gangsta
 
Join Date: Mar 2013
Posts: 510
Reputation: 15
Default Re: Issue with kicking players from an event

Solved.

Last edited by FunnyBear; 11/04/2017 at 01:52 AM.
FunnyBear is offline   Reply With Quote
Old 10/12/2016, 09:16 PM   #8
FunnyBear
Gangsta
 
Join Date: Mar 2013
Posts: 510
Reputation: 15
Default Re: Issue with kicking players from an event

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.
FunnyBear is offline   Reply With Quote
Old 10/12/2016, 09:27 PM   #9
Yaa
Banned
 
Join Date: May 2016
Location: = GetPlayerHouse("Yaa", 0.2);
Posts: 597
Reputation: 42
Default Re: Issue with kicking players from an event

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;

Yaa is offline   Reply With Quote
Old 10/12/2016, 09:31 PM   #10
FunnyBear
Gangsta
 
Join Date: Mar 2013
Posts: 510
Reputation: 15
Default Re: Issue with kicking players from an event

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?
FunnyBear is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
When kicking players ban info erase SalmaN97 Scripting Help 3 04/11/2015 12:58 AM
NPCs kicking players 6Dragon6 Scripting Help 3 28/03/2014 09:36 PM
Kicking Paused Players Michael[NBK] Scripting Help 3 11/11/2011 08:53 PM
AntiCheat Kicking Innocent Players [WF]Demon Help Archive 1 15/12/2010 04:12 AM


All times are GMT. The time now is 11:01 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.