BAN command problem
#1

Could someone edit this ban command? I tried to ban a NPC, but i got banned from the server my self.

Код:
if(!strcmp(cmdtext, "/ban", true,4))
{
new vardas[MAX_PLAYER_NAME];
strmid(vardas,GetArgument(1, cmdtext,0),0,MAX_PLAYER_NAME);
if(!strcmp(vardas, "0", true) ){SendClientMessage(playerid, COLOR, "* Blokuoti zaideja: /ban [dalis vardo]"); return 1;}
new id = GetPlayeridMid(vardas);
if (id == INVALID_PLAYER_ID){ SendClientMessage(playerid, COLOR, "* Tokio zaidejo nera"); return 1;}
if (playerDB[id][admin]){ SendClientMessage(playerid, COLOR, "* Administratoriaus ismesti negalima."); return 1;}

SetPVarInt(playerid, "playerid", playerid);
ShowPlayerDialog(playerid, 40, DIALOG_STYLE_LIST,"Blokavimo Priezastis","Zaidima palengvinancios programos\nReklamavimas\nNepagarba\nDeathMatch\nKita","Blokuoti","Atsaukti");
return 1;
}
Код:
if(dialogid == 40) {
if(response) {
BanEx(GetPVarInt(playerid, "playerid"), inputtext);
}
DeletePVar(playerid, "playerid");
return true;
}
It would be nice if someone added this and made it work to the command in the OnDialogResponse, I have dificulties saving names and similar stuff from a command to OnDialogResponse, i would be very grateful for it.

Код:
new msg[128];
format(msg,sizeof(msg),"[BAN] %s bannned player %s: (%s).",adminame,name,inputtext);
SendClientMessageToAll(COLOR,msg);
Reply
#2

pawn Код:
SetPVarInt(playerid, "playerid", playerid);
You're storing the person who did the command in the PVar? You should be storing the ID of the person you mean to kick, which seemingly according to your code is stored in the "id" variable, so your code should become this:

pawn Код:
SetPVarInt(playerid, "playerid", id);
Reply
#3

And how do i get the players and the admins names so i could add them OnDialogResponse?
Reply
#4

Using GetPlayerName: https://sampwiki.blast.hk/wiki/GetPlayerName
Reply
#5

I know the fuction but how do i get them from the /ban command so they could work in the lines that are under OnDialogRespone?
Reply
#6

I think that the problem is that you are actually banning "playerid" which is yourself.
Reply
#7

Quote:
Originally Posted by Max_Coldheart
Посмотреть сообщение
I think that the problem is that you are actually banning "playerid" which is yourself.
Yes this problem is fixed already thanks to JaTochNietDan
Reply
#8

The same way you already did it using the BanEx function!

pawn Код:
BanEx(GetPVarInt(playerid, "playerid"), inputtext);
// Apply the same logic to GetPlayerName
new name[24];
GetPlayerName(GetPVarInt(playerid, "playerid"), name);
Reply
#9

Thanks everyone, the ban command is now ready for use.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)