Kicking with YSI
#1

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
Reply
#2

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
Reply
#3

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?
Reply
#4

That helped me alot, how to force someone to login first (before spawning) with the YSI user system?
Reply
#5

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;
}
Reply
#6

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;
}
Reply
#7

Nevermind. I'll just use what Seif used. (What you just posted here, wasn't my question. But still, thank you. )
Reply
#8

******, 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
Reply
#9

Yes, I'am.
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)