BAN command problem -
Osviux - 26.05.2011
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);
Re: BAN command problem -
JaTochNietDan - 26.05.2011
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);
Re: BAN command problem -
Osviux - 26.05.2011
And how do i get the players and the admins names so i could add them OnDialogResponse?
Re: BAN command problem -
JaTochNietDan - 26.05.2011
Using GetPlayerName:
https://sampwiki.blast.hk/wiki/GetPlayerName
Re: BAN command problem -
Osviux - 26.05.2011
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?
Re: BAN command problem - Max_Coldheart - 26.05.2011
I think that the problem is that you are actually banning "playerid" which is yourself.
Re: BAN command problem -
Osviux - 26.05.2011
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
Re: BAN command problem -
JaTochNietDan - 26.05.2011
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);
Re: BAN command problem -
Osviux - 26.05.2011
Thanks everyone, the ban command is now ready for use.