Need help with zcmd /ban command.
#1

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;
}
Reply
#2

Where / how do you usually save data? OnPlayerDisconnect?
Reply
#3

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;
}
Reply
#4

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)