Jump to content
  • 0

Problema ban offline.


Bogdan's

Question

Problema intalnita (descriere): Deci am gasit pe net o comanda(/banoff) si voiam sa o adaug pe serverul meu care e pe dini.

Ok,totul bine,imi da doar o eroare am pus #pragma unused params si imi da mai multe erori.
Ero(area / rile) / warning-(ul / urile): (41247) : error 017: undefined symbol "params"

(41246) : warning 219: local variable "string" shadows a variable at a preceding level
Liniile de cod / sursa / script-ul(obligatoriu):

if(strcmp(cmd, "/banoff", true) == 0)
	{
    if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid,-1,"{AA3333}ERROR:{FFFFFF} Only administrators may use this command.");
    {
//Warning        new targetid, reason[128], string[128], string2[128];
//Eroare        if(sscanf(params,"us[128]",targetid,reason)) return SendClientMessage(playerid,-1,"{AA3333}USAGE:{FFFFFF} /abanaccount (id) (reason)");
        format(string,128,"{AA3333}AdminWARNING:{FFFFFF} %s attempted to ban your account, for reason: %s.",RemoveUnderScore(playerid),reason);
        if(PlayerInfo[playerid][pAdmin] < PlayerInfo[targetid][pAdmin] || PlayerInfo[targetid][pAdmin] == 1338) return SendClientMessage(targetid,-1,string) && SendClientMessage(playerid,-1,"{AA3333}ERROR:{FFFFFF} You cannot ban that players account.");
		{
		    PlayerInfo[targetid][pLocked] = 1;
		    for(new i = 0; i < MAX_PLAYERS; i++)
	    	{
	        	if(IsPlayerConnected(i))
	        	{
	            	if(PlayerInfo[pAdmin] > 1)
	            	{
						format(string2,128,"{AA3333}AdmCmd:{FFFFFF} %s has banned %s's account, for reason: %s",RemoveUnderScore(playerid),RemoveUnderScore(targetid),reason);
						SendClientMessage(i,-1,string2);
						Kick(targetid);
					}
				}
			}
		}
	}
	return 1;
}

Imagini / Video (optional): Am pus intre // linia cu eroare si imi da buguita comanda...
Ati incercat sa rezolvati singur?: Da,am cautat pe net dar nu am reusit sa o rezolv.

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0
	    if(strcmp(cmd, "/banoff", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
	    	tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "{00A1FF}USAGE{FFFFFF}: /banoff [AccountName] [reason]");
				return 1;
			}
			if (PlayerInfo[playerid][pAdmin] >= 1337 )
			{

				GetPlayerName(playerid, sendername, sizeof(sendername));
				new length = strlen(cmdtext);
				while ((idx < length) && (cmdtext[idx] <= ' '))
				{
					idx++;
				}
				new offset = idx;
				new result[64];
				while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
				{
					result[idx - offset] = cmdtext[idx];
					idx++;
				}
    			result[idx - offset] = EOS;
				if(!strlen(result))
				{
					SendClientMessage(playerid, COLOR_GRAD2, "{00A1FF}USAGE{FFFFFF}: /banoff [AccountName] [reason]");
					return 1;
				}
				format(string, sizeof(string), "users/%s.ini", tmp);
				if ( !fexist ( string ) )
					return SendClientMessage ( playerid, -1, "* Nu exista un jucator cu acel nume ." );
				freplaceline ( string, "Locked=0n", "Locked=1n" );
				new year, month,day;
				getdate(year, month, day);
				format(string, sizeof(string), "%s, was locked by, %s, reason:, %s, (%d-%d-%d), LockAcc,", tmp, sendername, (result),day,month,year);
				BanLog(string);
				format(string, sizeof(string), "[SERVER] Account %s was locked by %s, reason: %s", tmp, sendername, (result));
				ABroadCast(COLOR_LIGHTRED,string,1);
			}
			else
			{
				format(string, sizeof(string), "Nu ai acces sa utilizezi aceasta camanda", giveplayerid);
				SendClientMessage(playerid, COLOR_GRAD1, string);
			}
		}
		return 1;
	}
  • Upvote 1

Respect acestei comunitati, dar mai presus respect membrilor ei !

Link to comment
Share on other sites

  • 0

Error:  error 017: undefined symbol "freplaceline"

freplaceline ( string, "Locked=0n", "Locked=1n" );

Am inlocuit cu:

dini_IntSet(string, "Locked", 1);

Si cum as putea sa adaug un log pentru comanda?Am facut asta:

OnGameModeInit

if (!fexist("BanOffline.ban")){
    new File:open = fopen("BanOffline.ban",io_write);
    if (open) fclose(open);
    }

Si in comanda am adaugat :

new File:BanOfflines = fopen("BanOffline.ban", io_append);

Si mi se creeaza folderul dar nu imi scrie nimic in el.

Edited by Bogdan's
Link to comment
Share on other sites

  • 0

Lasa ce ti-am dat eu si adauga stock-ul asta la sfarsitu-l gamemodului:

stock freplaceline ( const fName [ ], const fLine [ ], const fReplaceLine [ ] )
{
        if ( !fexist ( fName ) ) return 0;
        new
            File: fEdit,
            File: fNew,
            fNewName [ 64 ],
            fString [ 256 ]
        ;
        format ( fNewName, sizeof ( fNewName ), "%s_new", fName );
        fNew = fopen ( fNewName, io_write );

        fEdit = fopen ( fName, io_read );

        while ( fread ( fEdit, fString ) )
        {
                if ( !strcmp ( fString, fLine ) )
                {
                    fwrite ( fNew, fReplaceLine );
                }
                else
                {
                    fwrite ( fNew, fString );
                }
        }
        fclose ( fEdit );
        fclose ( fNew );

        fNew = fopen ( fNewName, io_read );
        fEdit = fopen ( fName, io_write );

        while ( fread ( fNew, fString ) )
        {
                fwrite ( fEdit, fString );
        }
        fclose ( fEdit );
        fclose ( fNew );

        fremove ( fNewName );
        return 1;
}
  • Upvote 1

Respect acestei comunitati, dar mai presus respect membrilor ei !

Link to comment
Share on other sites

  • 0

Salut,uite cea mai simpla metoda de a creea un log.

I.Faci un forward  cu un string si dupa un public, exemplu:

forward Banuri(string[]);
public Banuri(string[])
{
	new entry[256];
	format(entry, sizeof(entry), "%sn",string);
	new File:hFile;
	hFile = fopen("Banuri.log", io_append);
	fwrite(hFile, entry);
	fclose(hFile);
}

Bun,acum ca am facut aceasta chestie trebuie sa facem sa se salveze in acel fisier anumite date sau scris pe care o sa il pui tu,exemplul tau pentru ban:

new year, month,day;
				getdate(year, month, day);
				format(string, sizeof(string), "[Zi: %d | Luna: %d | An:%d]%s(offline) a fost banat de catre %s.Motiv:, %s.", day,month,year, tmp, sendername, (result));
				Banuri(string);

Bon,si tu ai acolo in comanda ceva cu BanLog(string); ,tu modifici in Banuri,si hopa,uite ca ti-ai facut logul la comanda.

Edited by Adrian_Petre

 

 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more details you can also review our Terms of Use and Privacy Policy.