PDA

View Full Version : /unban command


CH | FuDo
12/08/2013, 03:11 PM
Hi guys, I just find one gamemode, and I started to little edit it, but cmd unban doesn't work. Here is the cmd:

CMD:unban(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 1 && !IsPlayerAdmin(playerid))
{
SendClientMessage(playerid, -1, "{969696}({E30000}Greska!{969696}) Nisi admin!");
}
else if(PlayerInfo[playerid][pAdmin] <= 3)
{
SendClientMessage(playerid, -1, "{969696}({E30000}Greska!{969696}) Nisi ovlasten za tu akciju!");
}
else if(PlayerInfo[playerid][pAdminDuznost] == 0)
{
SendClientMessage(playerid, -1, "{969696}({E30000}Greska!{969696}) Niste na duznosti!");
}
else
{
new string[128], pathstring[128], targetname[MAX_PLAYER_NAME];
format(pathstring,sizeof(pathstring),"Korisnici/%s.ini",targetname);
if(sscanf(params, "s[24]", targetname))
{
SendClientMessage(playerid, -1, "{969696}Koristi: /unban [ Ime_Prezime ]");
SendClientMessage(playerid, -1, "{E30000}OBAVEZNO! {969696}Upisite tacno Ime i Prezime igraca!!!");
}
else if(!fexist(pathstring))
{
SendClientMessage(playerid, -1, "{969696}({E30000}Greska!{969696}) Taj racun ne postoji!");
}
else
{
new INI:File = INI_Open(pathstring);
INI_SetTag(File, "Korisnicki racun");
INI_WriteInt(File, "Banovan", 0);
INI_WriteString(File, "BanRazlog", "Nema");
INI_WriteString(File, "BanAdmin", "Nema");
INI_Close(File);
format(string, sizeof(string), "{00A1FF}Unbanali ste igraca {FFFFFF}%s{00A1FF}!", targetname);
SendClientMessage(playerid, -1, string);
}
}
return 1;
}

on the top of the script, I defined PATH, everything works good, but this don't. It just show that file doesn't exist. Like this: SendClientMessage(playerid, -1, "{969696}({E30000}Greska!{969696}) Taj racun ne postoji!");

Any help? Thanks.

dEcooR
12/08/2013, 03:14 PM
CMD:unban(playerid, params[])
{
new string[128], pathstring[128], targetname[MAX_PLAYER_NAME];
format(pathstring,sizeof(pathstring),"Korisnici/%s.ini",targetname);
if(sscanf(params, "s[24]", targetname))
{
SendClientMessage(playerid, -1, "{969696}Koristi: /unban [ Ime_Prezime ]");
SendClientMessage(playerid, -1, "{E30000}OBAVEZNO! {969696}Upisite tacno Ime i Prezime igraca!!!");
return 1;
}
else if(PlayerInfo[playerid][pAdmin] < 1 && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "{969696}({E30000}Greska!{969696}) Nisi admin!");
else if(PlayerInfo[playerid][pAdmin] <= 3) return SendClientMessage(playerid, -1, "{969696}({E30000}Greska!{969696}) Nisi ovlasten za tu akciju!");
else if(PlayerInfo[playerid][pAdminDuznost] == 0) return SendClientMessage(playerid, -1, "{969696}({E30000}Greska!{969696}) Niste na duznosti!");
else if(!fexist(pathstring)) return SendClientMessage(playerid, -1, "{969696}({E30000}Greska!{969696}) Taj racun ne postoji!");
else
{
new INI:File = INI_Open(pathstring);
INI_SetTag(File, "Korisnicki racun");
INI_WriteInt(File, "Banovan", 0);
INI_WriteString(File, "BanRazlog", "Nema");
INI_WriteString(File, "BanAdmin", "Nema");
INI_Close(File);
format(string, sizeof(string), "{00A1FF}Unbanali ste igraca {FFFFFF}%s{00A1FF}!", targetname);
SendClientMessage(playerid, -1, string);
}
return 1;
}

CH | FuDo
12/08/2013, 04:55 PM
Doesn't work. Thanks anyway.

Any other suggestions?

gtakillerIV
12/08/2013, 05:11 PM
new string[128], pathstring[128], targetname[MAX_PLAYER_NAME];
format(pathstring,sizeof(pathstring),"Korisnici/%s.ini",targetname);
if(sscanf(params, "s[24]", targetname))
{
SendClientMessage(playerid, -1, "{969696}Koristi: /unban [ Ime_Prezime ]");
SendClientMessage(playerid, -1, "{E30000}OBAVEZNO! {969696}Upisite tacno Ime i Prezime igraca!!!");
}

You just created targetname and you're already adding it to your path string.

Your path string should look something like this: Korisnici/.ini

The sscanf part has to be on top of the format function.

Like:

new string[128], pathstring[128], targetname[MAX_PLAYER_NAME];
if(sscanf(params, "s[24]", targetname))
{
SendClientMessage(playerid, -1, "{969696}Koristi: /unban [ Ime_Prezime ]");
SendClientMessage(playerid, -1, "{E30000}OBAVEZNO! {969696}Upisite tacno Ime i Prezime igraca!!!");
return 0;
}
format(pathstring,sizeof(pathstring),"Korisnici/%s.ini",targetname);

CH | FuDo
13/08/2013, 08:48 AM
I fixed it on my own. But, never mind, thank you both. + rep for answers.