PDA

View Full Version : unban cmd error


Sojo12
21/03/2014, 11:51 AM
I took this code from this forum only but im getting else erros and dont know how to fix it.Help will be appreciated.
Code:CMD:unban(playerid, params[])
{
new string[128];
new pName[24];
if(isnull(params)) return SendClientMessage(playerid, -1, "{FF0099}[ADMIN]{FFFFFF} /unban [playername]");
{
format(string, 128, "{FF0099}[ADMIN]{FFFFFF} '%s' has been unbanned by %s.", params,pName);
SendClientMessageToAll(COLOR_ADMIN,string);
new year, month,day;
getdate(year, month, day);
new playa[MAX_PLAYER_NAME];
GetPlayerName(playerid, playa, MAX_PLAYER_NAME);
format(string, sizeof(string), "{FF0099}[ADMIN]{FFFFFF} '%s' has been unbanned by %s.", params, playa);
SendClientMessageToAll(COLOR_ADMIN, string);
}
else
{
SendClientMessage( playerid, -1, "{FF0000}[ERROR]{FFFFFF}Not a banned account or no such account was found!" );
}
return 1;
}

MythicalMarauder
21/03/2014, 11:57 AM
Show us your errors?

Sojo12
21/03/2014, 12:06 PM
C:\Users\HACKIFYOUCAN\Desktop\NEW\FunGaming Stunt-Freeroam\gamemodes\SFCRRPG.pwn(5502) : error 029: invalid expression, assumed zero
In line 5502 its like this
}
else
}

UnknownOwner
21/03/2014, 12:13 PM
Must be:

}
else
{

Hanuman
21/03/2014, 12:19 PM
you need to define a condition

new string[128];
new pName[24];
if(isnull(params)) return SendClientMessage(playerid, -1, "{FF0099}[ADMIN]{FFFFFF} /unban [playername]");
if(//File present)//like this
{
format(string, 128, "{FF0099}[ADMIN]{FFFFFF} '%s' has been unbanned by %s.", params,pName);
SendClientMessageToAll(COLOR_ADMIN,string);

Sojo12
21/03/2014, 12:39 PM
@Unknown its like that only but i was unable to make it like that overhere.
Hanuman im testng it right now!NOt working.
Another one please

Carac
21/03/2014, 03:02 PM
I'm using this one CMD:unban(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pBanAppealer] >= 1)
{
if(AdminDuty[playerid] != 1 && PlayerInfo[playerid][pAdmin] < 5)
{
SendClientMessage(playerid,COLOR_WHITE, "You're not on-duty as admin. To access your admin commands you must be on-duty. Type /aduty to go on-duty.");
return 1;
}

new string[128];
if(isnull(params)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /unban [playername]");

if(doesAccountExist(params))
{
OnPlayerOfflineLogin(params);
if(PlayerInfo[MAX_PLAYERS][pPermaBanned] == 1)
{
SendClientMessage(playerid, COLOR_WHITE, "Permanently banned accounts can only be unbanned via FTP.");
}
else
{
if(PlayerInfo[MAX_PLAYERS][pBanned] >= 1)
{
PlayerInfo[MAX_PLAYERS][pBanned] = 0;

if(PlayerInfo[MAX_PLAYERS][pWarns] == 3)
PlayerInfo[MAX_PLAYERS][pWarns] = 0;

RemoveBan(PlayerInfo[MAX_PLAYERS][pIP]);
OnPlayerOfflineSave(params);
format(string, 128, "AdmCmd: %s (IP:%s) was unbanned by %s.", params, PlayerInfo[MAX_PLAYERS][pIP], GetPlayerNameEx(playerid));
ABroadCast(COLOR_LIGHTRED,string,2);
format(string, sizeof(string), "AdmCmd: %s (IP:%s) was unbanned by %s.", params, PlayerInfo[MAX_PLAYERS][pIP], GetPlayerNameEx(playerid));
Log("logs/ban.log", string);
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "Not a banned account!");
}
}
}
else
{
SendClientMessage(playerid, COLOR_WHITE, "That account doesn't exist.");
}
}
else
{
SendClientMessage(playerid, COLOR_GRAD1, "You're not authorized to use that command!");
}
return 1;
}

Konstantinos
21/03/2014, 03:13 PM
The command is incomplete. You check an if statement and then you return an error message. After than you open a bracket and do the code to unban (even though, it's just message. It doesn't actually unban the player) and then you check an else statement when you didn't use an if before. Like Hanuman said, you need to use an if statement that checks if the player is banned (everything depends on how you ban a player).

If you don't know how to make a simple ban/unban command by yourself, check some tutorials or filterscripts out. It will help you a lot!

Hanuman
21/03/2014, 03:15 PM
u are using dini or YSI?

Sojo12
21/03/2014, 03:31 PM
dini

Schocc
21/03/2014, 03:48 PM
Missed use GetPlayerName function.
referral link (http://wiki.sa-mp.com/wiki/Useful_Functions#Dini_.28Dini.inc.29)

e.g

CMD:unban(playerid,params[]) {
new dest[MAX_PLAYER_NAME+5], string[144];
new pName[MAX_PLAYER_NAME];

GetPlayerName(playerid, pName, sizeof(pName));

if(isnull(params))
return SendClientMessage(playerid, -1, "{FF0099}[ADMIN]{FFFFFF} /unban [playername]");

strcat(dest, params); // "", "ishock"
strcat(dest, ".ini"); // "ishock", ".ini" = "ishock.ini"

if( dini_Exists(dest) ) {
format(string, sizeof(string), "{FF0099}[ADMIN]{FFFFFF} '%s' has been unbanned by %s.", params, pName);
SendClientMessageToAll(-1, string);
dini_IntSet(dest,"PlayerBanned",0); // Reset flag
// or
dini_Set(dest,"PlayerBanned","0"); // Reset flag

} else {

SendClientMessage(playerid,-1, "Account not found!");
}
return 1;
}


@edit: ...

Sojo12
22/03/2014, 05:47 AM
Thanks a lot man.You deserve a rep.I did make the unban command by myself as suggested by Konstantinos.