Need help with zcmd /ban command. - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Need help with zcmd /ban command. (
/showthread.php?tid=547744)
Need help with zcmd /ban command. -
danielpalade - 24.11.2014
Hello all! I am trying to make my self a gamemode and i'm not that good yet at scripting. So I am now making the command /ban. As i was making it, i have found an error which didn't save the ban into the user's file.
It does ban him, but it just won't save.
Thanks in advance!
Here is my code:
Код:
CMD:ban(playerid, params[], help)
{
new id, reason[128], str1[128], str2[128],str3[128];
if(IsPlayerAdmin(playerid) || PlayerInfo[playerid][pAdmin]<=6)
if (sscanf(params, "ds[128]", id, reason)) SendClientMessage(playerid, 0x2B63CCFF, "[G-Zone]: {E6E6E6}/ban [playerid] [reason]");
else if (!IsPlayerConnected(id)) SendClientMessage(playerid, 0xFFED2D3AFF, "Invalid id");
else
{
format(str1, 128, "Admin: %s Banned: %s Reason: %s", GetName(playerid),GetName(playerid), reason);
SendClientMessageToAll(0xFFED2D3AFF,str1);
format(str2, 128, "You have been Banned from the server by Admin: %s Reason: %s",GetName(playerid), reason);
SendClientMessage(id, 0xFFED2D3AFF, str2);
format(str3, 128, "~r~~h~Banned ~n~~r~");
GameTextForPlayer(id, str3, 6000, 3);
PlayerInfo[playerid][pBanned]= 1;
Kick(id);
}
else
{
SendClientMessage(playerid, 0xFFFFFFFF, "You are not authorized to use that command!");
}
return 1;
}
Re: Need help with zcmd /ban command. -
DobbysGamertag - 24.11.2014
Where / how do you usually save data? OnPlayerDisconnect?
Re: Need help with zcmd /ban command. -
danielpalade - 24.11.2014
Yes, this is the code i have there.
Код:
public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Level",GetPlayerScore(playerid));
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]);
return 1;
}
Re: Need help with zcmd /ban command. -
Banana_Ghost - 25.11.2014
pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Level",GetPlayerScore(playerid));
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Banned",PlayerInfo[playerid][pBanned]);
INI_Close(File);
return 1;
}
You need to close the file once you are done with it.