SA-MP Forums

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

 
 
Thread Tools Display Modes
Old 15/11/2009, 10:40 AM   #1
KnooL
Huge Clucker
 
Join Date: Jan 2009
Posts: 411
Reputation: 3
Default Kicking with YSI

Hello,

I'am using YSI (Author: ******), basic scripting.
I want to kick, slap, giveauthority, makeleader and so on.
At this moment I only can do that on myself (ex. /kickme)
Now, you have this kick command without YSI
Code:
//----------------------------- [ KICK ]----------------------------------------
	if(strcmp(cmd, "/kick", true, 10) == 0)
{
	tmp = strtok(cmdtext, idx);
	if(!strlen(tmp))
{
	SendClientMessage(playerid, COLOR_YELLOW, "[!] USAGE: /kick [playerid] (auto assigned reason)");
	return 1;
}
	new playa = strval(tmp);
	GetPlayerName(playa, giveplayer, sizeof(giveplayer));
	GetPlayerName(playerid, sendername, sizeof(sendername));
	if(pAdmin[playerid] >= 1)
{
	if(logged[playerid] == 1)
{
	SendClientMessage(playa, COLOR_RED, "You were kicked from the server!");
	format(string, sizeof(string), "[!] AdmCmd: %s was kicked by %s, Reason: Behaving Innapropriatly",sendername, giveplayer);
	SendClientMessageToAll(COLOR_ADMIN, string);
	Kick(playa);
	return 1;
}
}
	else
{
	SendClientMessage(playerid, COLOR_RED, "[!] You cannot use this command!");
}
	return 1;
}
How is it made on YSI (Author: ******) ?

ex. kill command of ysi
Code:
Command_(kill)
{
	if (help)
	{
		// The player typed "/help drop" not "/drop"
		Text_Send(playerid, "KILL_HELP");
	}
					else if (IsPlayerAdmin(playerid))
	{
		// Player typed "/kill"
		SetPlayerHealth(playerid, 0.0);
	}
	else
	{
	  Text_Send(playerid, "NO_ADMIN");
	}
	return 1;
}
KnooL
__________________
217.18.70.94:7777
http://mafiacityrpg.com
Quote:
Originally Posted by bajskorv123 View Post
Will returning 0 at OnPlayerDisconnect work?
Just a quick question because im too lazy to test.
Would be nice if you could keep players on server xD
KnooL is offline  
Old 15/11/2009, 11:43 AM   #2
Google63
Big Clucker
 
Join Date: Jun 2008
Posts: 113
Reputation: 0
Default Re: Kicking with YSI

Command_(cmd) is actually macro for Command_Add(), It works because it adds arguments you don't see in adding(playerid, params[], help) so you can kill yourself(as playerid is passed as yours id).

Best solution to your problem is: sscanf
Google63 is offline  
Old 15/11/2009, 11:54 AM   #3
KnooL
Huge Clucker
 
Join Date: Jan 2009
Posts: 411
Reputation: 3
Default Re: Kicking with YSI

So I add the
pawn Code:
stock sscanf(string[], format[], {Float,_}:...)
thing into my script.
And can you give me an example how it is going to look?
__________________
217.18.70.94:7777
http://mafiacityrpg.com
Quote:
Originally Posted by bajskorv123 View Post
Will returning 0 at OnPlayerDisconnect work?
Just a quick question because im too lazy to test.
Would be nice if you could keep players on server xD
KnooL is offline  
Old 15/11/2009, 03:29 PM   #4
KnooL
Huge Clucker
 
Join Date: Jan 2009
Posts: 411
Reputation: 3
Default Re: Kicking with YSI

That helped me alot, how to force someone to login first (before spawning) with the YSI user system?
__________________
217.18.70.94:7777
http://mafiacityrpg.com
Quote:
Originally Posted by bajskorv123 View Post
Will returning 0 at OnPlayerDisconnect work?
Just a quick question because im too lazy to test.
Would be nice if you could keep players on server xD
KnooL is offline  
Old 16/11/2009, 03:07 PM   #5
KnooL
Huge Clucker
 
Join Date: Jan 2009
Posts: 411
Reputation: 3
Default Re: Kicking with YSI

My version: else if (IsPlayerConnected(player))
pawn Code:
Command_(kill)
{
    if (help)
    {
    Text_Send(playerid, "KILL_HELP");
    Text_SendFormat(playerid, "KILL_HELP1", "kill");
    }
    else
    {
    if (sscanf(params, "u", player))
    {
    Text_Send(playerid, "KILL_HELP");
    Text_SendFormat(playerid, "KILL_HELP1", "kill");
    }
    else if (IsPlayerConnected(player))
    {
    SetPlayerHealth(player, 0.0);
    Text_SendToAllFormat("ADMIN_PLAYERKILLED", ReturnPlayerName(playerid), playerid, ReturnPlayerName(player), player);
    }
    }
    return 1;
}

Your version: else
{
if (IsPlayerConnected(player))
{

Which option do I have to use?
pawn Code:
Command_(kick)
{
if (help)
{
Text_Send(playerid, "KICK_HELP");
Text_SendFormat(playerid, "KICK_HELP1", "kick");
}
else
{
if (sscanf(params, "u", player))
{
Text_Send(playerid, "KICK_HELP");
Text_SendFormat(playerid, "KICK_HELP1", "kick");
}
else
{
if (IsPlayerConnected(player))
{
Kick(player);
Text_SendFormat(player, "YOURE_KICKED", ReturnPlayerName(playerid), playerid);
Text_SendToAllFormat("THEYRE_KICKED", ReturnPlayerName(player), player, ReturnPlayerName(playerid), playerid);
}
else
{
Text_SendFormat(playerid, "NOT_CONNECTED", player);
}
}
}
return 1;
}
__________________
217.18.70.94:7777
http://mafiacityrpg.com
Quote:
Originally Posted by bajskorv123 View Post
Will returning 0 at OnPlayerDisconnect work?
Just a quick question because im too lazy to test.
Would be nice if you could keep players on server xD
KnooL is offline  
Old 16/11/2009, 03:30 PM   #6
Zeex
Guest
 
Posts: n/a
Default Re: Kicking with YSI

If you use the "u" format character in sscanf then you don't need to check if the player connected, just make sure his ID isn't eqaul to INVALID_PLAYER_ID

pawn Code:
Command_(kick)
{
    if (help)
    {
        Text_Send(playerid, "KICK_HELP");
        Text_SendFormat(playerid, "KICK_HELP1", "kick");
    }
    else
    {
        if (sscanf(params, "u", player))
        {
            Text_Send(playerid, "KICK_HELP");
            Text_SendFormat(playerid, "KICK_HELP1", "kick");
        }
        else
        {
            if (player != INVALID_PLAYER_ID)
            {
                Kick(player);
                Text_SendFormat(player, "YOURE_KICKED", ReturnPlayerName(playerid), playerid);
                Text_SendToAllFormat("THEYRE_KICKED", ReturnPlayerName(player), player, ReturnPlayerName(playerid), playerid);
            }
            else
            {
                Text_SendFormat(playerid, "NOT_CONNECTED", player);
            }
        }
    }
    return 1;
}
 
Old 16/11/2009, 05:26 PM   #7
KnooL
Huge Clucker
 
Join Date: Jan 2009
Posts: 411
Reputation: 3
Default Re: Kicking with YSI

Nevermind. I'll just use what Seif used. (What you just posted here, wasn't my question. But still, thank you. )
__________________
217.18.70.94:7777
http://mafiacityrpg.com
Quote:
Originally Posted by bajskorv123 View Post
Will returning 0 at OnPlayerDisconnect work?
Just a quick question because im too lazy to test.
Would be nice if you could keep players on server xD
KnooL is offline  
Old 17/11/2009, 01:31 PM   #8
KnooL
Huge Clucker
 
Join Date: Jan 2009
Posts: 411
Reputation: 3
Default Re: Kicking with YSI

******, you told me to use:
pawn Code:
Group_SetCommand(gGroupCop, "makecop", true);
Group_SetDefaultCommand("makecop", false);
to set a command for a group.
This ain't working, it tells me
Code:
Server: Unknown Command
__________________
217.18.70.94:7777
http://mafiacityrpg.com
Quote:
Originally Posted by bajskorv123 View Post
Will returning 0 at OnPlayerDisconnect work?
Just a quick question because im too lazy to test.
Would be nice if you could keep players on server xD
KnooL is offline  
Old 18/11/2009, 11:56 AM   #9
KnooL
Huge Clucker
 
Join Date: Jan 2009
Posts: 411
Reputation: 3
Default Re: Kicking with YSI

Yes, I'am.
__________________
217.18.70.94:7777
http://mafiacityrpg.com
Quote:
Originally Posted by bajskorv123 View Post
Will returning 0 at OnPlayerDisconnect work?
Just a quick question because im too lazy to test.
Would be nice if you could keep players on server xD
KnooL is offline  
Old 19/11/2009, 02:51 PM   #10
KnooL
Huge Clucker
 
Join Date: Jan 2009
Posts: 411
Reputation: 3
Default Re: Kicking with YSI

Above public OnGameModeInit()

pawn Code:
Command_(makecop)
{
if (help)
{
Text_Send(playerid, "INVITE_HELP");
Text_SendFormat(playerid, "INVITE_HELP1", "makecop");
}
else
{
if (sscanf(params, "u", player))
{
Text_Send(playerid, "INVITE_HELP");
Text_SendFormat(playerid, "INVITE_HELP1", "makecop");
}
else if (IsPlayerConnected(player))
{
Group_RemovePlayer(gCitizenGroup, player);
Group_AddPlayer(gPoliceGroup, player);
Group_AddPlayer(gPoliceOfficerGroup, player);
Text_SendToGroupFormat(gPoliceGroup, "NEWCOP_INVITED", ReturnPlayerName(playerid), playerid, ReturnPlayerName(player), player);
}
}
return 1;
}

In public OnGameModeInit()
pawn Code:
ycmd("makecop");
Group_SetCommand(gPoliceChiefGroup, "makecop", true);
Group_SetDefaultCommand("makecop", false);

PoliceChiefGroup:

Top of script under #include
pawn Code:
new
    player,
    gAdminGroup,
    gPoliceGroup,
    gPoliceOfficerGroup,
    gPoliceChiefGroup,
    gPoliceLieutenantGroup,
    gPoliceSergeantGroup,
    gCitizenGroup,
    gPlayerLoggedIn[MAX_PLAYERS] = {-1, ...},
    gPlayerDeaths[MAX_PLAYERS],
    gPlayerKills[MAX_PLAYERS];

No admin requirements setted because it isn't yet working
making someone a cop leader above public OnGameModeInit():
pawn Code:
Command_(makecopleader)
{
    if (help)
    {
    Text_Send(playerid, "MAKELEADER_HELP");
    Text_SendFormat(playerid, "MAKELEADERCOP1_HELP", "makecopleader");
    }
    else
    {
    if (sscanf(params, "u", player))
    {
    Text_Send(playerid, "MAKELEADER_HELP");
    Text_SendFormat(playerid, "MAKELEADERCOP1_HELP", "makecopleader");
    }
    else if (IsPlayerConnected(player))
    {
    Group_AddPlayer(gPoliceChiefGroup, player);
    Group_AddPlayer(gPoliceGroup, player);
    Text_SendFormat(playerid, "NEWLEADER_SETTED", ReturnPlayerName(player), player);
    Text_SendFormat(player, "TONEW_SETTEDLEADER", ReturnPlayerName(playerid), playerid);
    Text_Send(player, "TONEW_SETTEDLEADER1");
    Text_SendToAllFormat("NEW_LSPD_LEADER", ReturnPlayerName(playerid), playerid, ReturnPlayerName(player), player);
    }
    }
return 1;
}


In public OnGameModeInit()
pawn Code:
gPoliceChiefGroup = Group_Create("LSPD Chiefs");

In public OnGameModeInit()
pawn Code:
Class_AddForGroup(gPoliceChiefGroup, 282, 1585.2401, -1667.5132, 5.6245, 0, 0, 0, 0, 0, 0);
    Class_AddForGroup(gPoliceChiefGroup, 288, 1585.2401, -1667.5132, 5.6245, 0, 0, 0, 0, 0, 0);
    Class_AddForGroup(gPoliceChiefGroup, 283, 1585.2401, -1667.5132, 5.6245, 0, 0, 0, 0, 0, 0);

Note: Without setting the group commands, it works well.
__________________
217.18.70.94:7777
http://mafiacityrpg.com
Quote:
Originally Posted by bajskorv123 View Post
Will returning 0 at OnPlayerDisconnect work?
Just a quick question because im too lazy to test.
Would be nice if you could keep players on server xD
KnooL is offline  
 

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
Kicking low score's from helicopters: Need help CrucixTM Scripting Help 17 04/01/2013 05:31 PM
Not kicking me from the vehicle Torran Help Archive 2 21/03/2010 11:38 PM
Ping Kicking BP13 Server Support 3 21/03/2010 03:27 PM
Not kicking player from vehicle? Torran Help Archive 8 10/03/2010 03:32 PM


All times are GMT. The time now is 07:51 PM.


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