help with /kick and /ban
#1

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

What are you trying to do exactly?
Reply
#3

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

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

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

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

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

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.");
Reply
#9

Thank you so much SilentSoul.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)