SA-MP Forums Archive
help with /kick and /ban - 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: help with /kick and /ban (/showthread.php?tid=470781)



help with /kick and /ban - NaziHotdog - 19.10.2013

I'm doing a very quick admin system for simple server for me and my friends,and can't seem to make /kick and /ban system properly.
Basicly:
You have admin level 1
if yes then kick
if no then "get a admin noob"

You have admin level 1
if yes then ban
if no then "get a admin noob"

I searched whole forums and can't find anything.
Better if simple.By the way I use y_ini register system and just write admin=1 there,but reading from y_ini didn't seem to work here.

Help!


Re: help with /kick and /ban - Akira297 - 19.10.2013

What are you trying to do exactly?


Re: help with /kick and /ban - DanishHaq - 19.10.2013

Can you show us what you've done up to now? And can you show us how you load / save your variables too? That'd help us.

Quote:
Originally Posted by Akira297
Посмотреть сообщение
What are you trying to do exactly?
He wants a kick and ban command that reads off the variables of Admin='%d', if the sender is not admin, it should return "get a admin noob". I think that's what he wants.


Re: help with /kick and /ban - NaziHotdog - 19.10.2013

Quote:
Originally Posted by DanishHaq
Посмотреть сообщение
Can you show us what you've done up to now? And can you show us how you load / save your variables too? That'd help us.



He wants a kick and ban command that reads off the variables of Admin='%d', if the sender is not admin, it should return "get a admin noob". I think that's what he wants.
that's right.exluding that 'get a admin noob' was a example.a misspelled example.


Код:
CMD:kick(playerid, params[])
{
        if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid,-1,"Admins Only");
        new tmp[128];
		tmp = strtok(cmdtext, idx);

		Kick(strval(tmp));
        return 1;
}
that's one of the ways I tried to do that.


Re: help with /kick and /ban - DanishHaq - 19.10.2013

If you download sscanf plugin by ******, you can do this which is a lot easier:

pawn Код:
CMD:kick(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, -1, "Admins only.");
    new targetid;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "Syntax: /kick [playerid/name]");
    Kick(targetid);
    return 1;
}
And here's a proper kick command that you might like too, made this in the 240 seconds of waiting between posts .

pawn Код:
CMD:kick(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, -1, "Admins only.");
    new targetid, reason[50];
    if(sscanf(params, "us[50]", targetid, reason)) return SendClientMessage(playerid, -1, "Syntax: /kick [playerid/name] [reason]");
    if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Error: Player not connected.");
    new string[100], sendername[MAX_PLAYER_NAME], receivername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, sendername, sizeof(sendername));
    GetPlayerName(targetid, receivername, sizeof(receivername));
    format(string, sizeof(string), "%s has been kicked by %s, reason: %s", receivername, sendername, reason);
    SendClientMessageToAll(COLOR_WHITE, string);
    return 1;
}



Re: help with /kick and /ban - NaziHotdog - 19.10.2013

Now,I get this:

Код:
C:\Users\Kompas\Desktop\fag\filterscripts\admin.pwn(8) : error 017: undefined symbol "PlayerInfo"
C:\Users\Kompas\Desktop\fag\filterscripts\admin.pwn(8) : warning 215: expression has no effect
C:\Users\Kompas\Desktop\fag\filterscripts\admin.pwn(8) : error 001: expected token: ";", but found "]"
C:\Users\Kompas\Desktop\fag\filterscripts\admin.pwn(8) : error 029: invalid expression, assumed zero
C:\Users\Kompas\Desktop\fag\filterscripts\admin.pwn(8) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
my script:

Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#include <YSI\y_ini>

CMD:kick(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, -1, "Admins only.");
    new targetid;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "Syntax: /kick [playerid/name]");
    Kick(targetid);
    return 1;
}
8th line is here:
Код:
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, -1, "Admins only.");
I have so many includes just in case.My register system in y_ini works just fine.


Re: help with /kick and /ban - DanishHaq - 19.10.2013

If that is your whole script, you're not saving or loading anything from y_ini. Make a registration / login system first with this tutorial: https://sampforum.blast.hk/showthread.php?tid=273088 and then this will work.


Re: help with /kick and /ban - SilentSoul - 19.10.2013

Quote:
Originally Posted by NaziHotdog
Посмотреть сообщение
Now,I get this:

Код:
C:\Users\Kompas\Desktop\fag\filterscripts\admin.pwn(8) : error 017: undefined symbol "PlayerInfo"
C:\Users\Kompas\Desktop\fag\filterscripts\admin.pwn(8) : warning 215: expression has no effect
C:\Users\Kompas\Desktop\fag\filterscripts\admin.pwn(8) : error 001: expected token: ";", but found "]"
C:\Users\Kompas\Desktop\fag\filterscripts\admin.pwn(8) : error 029: invalid expression, assumed zero
C:\Users\Kompas\Desktop\fag\filterscripts\admin.pwn(8) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
my script:

Код:
#include <a_samp>
#include <zcmd>
#include <sscanf2>
#include <YSI\y_ini>

CMD:kick(playerid, params[])
{
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, -1, "Admins only.");
    new targetid;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "Syntax: /kick [playerid/name]");
    Kick(targetid);
    return 1;
}
8th line is here:
Код:
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, -1, "Admins only.");
I have so many includes just in case.My register system in y_ini works just fine.
Change PlayerInfo to your enum admin stats and try that for example i use this
pawn Код:
enum pInfo
{
    pPass,
    pCash,
    pKills,
    pDeaths,
    pAdminLevel
}
new PlayerInfo[MAX_PLAYERS][pInfo]; // so my enum uses PlayerInfo[playerid][pAdminLevel]
And edit that...
pawn Код:
if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, -1, "Admins only.");



Re: help with /kick and /ban - NaziHotdog - 19.10.2013

Thank you so much SilentSoul.