SA-MP Forums Archive
Why the ban is not loading - 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: Why the ban is not loading (/showthread.php?tid=625106)



Why the ban is not loading - 1fret - 28.12.2016

So i made a ban command and i set it that when a player gets banned it should set pInfo[playerid][banned] = 1; , which it does and save successfully but when the player connects and i check under onplayerreqestclass if the player is banned = 1; it doesnt kick the player it still spawn them..

Код:
CMD:ban(playerid, params[])
{
    new targetid, reason[24];
    if(sscanf(params, "us[24]", targetid, reason)) return SendClientMessage(playerid,error, "[USAGE]: /ban [PlayerName/Playerid] [reason]");
    if(strlen(reason) < 1 || strlen(reason) > 100) return SendClientMessage(playerid, error, "Your reason can only contain 1-100 characters.");
    if(targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid, error, "Player not found.");
    {
        pInfo[targetid][Banned] = 1;
        format(astring, sizeof(astring), "AdmCmd: %s [%d] has been Banned by an Administrator.[Reason: %s]",GetName(targetid), targetid, reason);
        SendClientMessageToAll(red, astring);
        GameTextForPlayer(targetid, "~r~Banned", 5000, 5);
        format(astring, sizeof(astring), "AdmCmd: You have been banned from the server. You were banned by Administrator %s.", GetName(playerid));
        SendClientMessage(targetid, red, astring);
        SendClientMessage(targetid, red, "AdmCmd: If you think this ban is unfair post an appeal on our forums and take a screen shot of this message.");
        SetTimerEx("BanPlayer",200,false,"ud", targetid,2);

    }
    return true;
}
// onplayerrequestclass
if(pInfo[playerid][Banned] == 1)
    {
		SendClientMessage(playerid,red, "AdmCmd: This Account has been banned from the server.");
        SetTimerEx("KickPlayer",200,false,"u", playerid);
        format(astring, sizeof(astring),"AdmCmd: %s has been automatically kicked | reason: Account Banned", GetName(playerid));
        SendToAdmins(orange,astring);
        format(astring,sizeof(astring),"AdmCmd: %s has been kicked | Reason: Account Banned",GetName(playerid));
		WriteToLog(astring,"AccKickLog");
    }
I used this tutorial for how to check if the player is banned.
https://sampforum.blast.hk/showthread.php?tid=388612


Re: Why the ban is not loading - coool - 28.12.2016

You have'nt saved it in any file.
Use the tutorial again.


Re: Why the ban is not loading - 1fret - 28.12.2016

Quote:
Originally Posted by coool
Посмотреть сообщение
You have'nt saved it in any file.
Use the tutorial again.
As i mention above , i saved it successfully....

Код:
enum PlayerInfo
{
    Pass,
    Cash,
	Admin,
    Kills,
    Deaths,
    Score,
    Banned,
    OnDuty,
	Playing,
	Hidden,
	Spawned,
	MaxRcon,
	LastSpawnedCar,
	dCars[MAX_CAR_SPAWNS],
	dSpawnedCars,
   	LoginAttempts,
   	Spec,
   	Warns,
   	Frozen
}

forward SaveChar(playerid);
public SaveChar(playerid)
{
   	if(!IsPlayerConnected(playerid)) return 1;
	new INI:ACCOUNT = INI_Open(UserPath(playerid));
	INI_SetTag(ACCOUNT,"data");
	INI_WriteInt(ACCOUNT,"Level",pInfo[playerid][Admin]);
    INI_WriteInt(ACCOUNT,"Cash",GetPlayerCash(playerid));
	INI_WriteInt(ACCOUNT,"Kills",pInfo[playerid][Kills]);
	INI_WriteInt(ACCOUNT,"Deaths",pInfo[playerid][Deaths]);
	INI_WriteInt(ACCOUNT, "Score",GetPlayerScore(playerid));
    INI_WriteInt(ACCOUNT, "Banned",pInfo[playerid][Banned]);
  	INI_Close(ACCOUNT);
    new string[100];
	format(string, 100, "%s's character has saved successfully.", GetName(playerid));
	print(string);
    return 1;
}



Re: Why the ban is not loading - coool - 28.12.2016

I don't think that the error is created by the code mentioned above


Re: Why the ban is not loading - RedRex - 28.12.2016

Type this in GM/FS

Код:
#define PATH "/bans/%s.ini"
And Go scirptfile and create File Name bans



Re: Why the ban is not loading - 1fret - 28.12.2016

Thanks for the help, but I fixed it, the issue was a bug in the script and as I said it saved properly..