Jump to content
  • 0

Admin system [nerezolvat]


Alexandru Alex

Question

Salut SA-MP.RO, m-am apucat de un gamemode de la 0 si vreau sa fac un sistem de admin, am incercat unul dar nu este bun

CMD:setlevel(playerid, params[])
{
    new iD, Level, gMessage[250], gVictim[24];
    if(IsPlayerAdmin(playerid) == 1)
    {
        if(sscanf(params, "ui", iD, Level)) return SendClientMessage(playerid, 0xFF0000FF, "* Usage: /setlevel [playerid] [level]");
        else if(iD == playerid) return SendClientMessage(playerid, 0xFF0000FF, "* You cannot use that command on yourself");
        else if(!IsPlayerConnected(iD)) return SendClientMessage(playerid, 0xFF0000FF, "* That player is offline.");
        else
        {
            GetPlayerName(playerid, pName, sizeof(pName));
            GetPlayerName(iD, gVictim, sizeof(gVictim));
            format(gQuery, sizeof(gQuery), "UPDATE Users SET Admin = '%i' WHERE Name = '%s'", Level, pName);
            mysql_query(gQuery);
            
            format(gMessage, sizeof(gMessage), "* You have set %s an admin. Level: %i", gVictim, Level);
            SendClientMessage(playerid, 0xFFFFFFFF, gMessage);
            
            format(gMessage, sizeof(gMessage), "* You have been set as a level %i admin.", Level);
            SendClientMessage(playerid, 0xFFFFFFFF, gMessage);
            
            pInfo[iD][Admin] = Level;
        }
    }
    else
    {
        SendClientMessage(playerid, 0xFF0000FF, "* You are not an admin.");
    }
    return 1;
}

acest sistem este de pe net. dar imi da erori

error 035: argument type mismatch (argument 2)
error 039: constant symbol has no size
error 035: argument type mismatch (argument 1)
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line

si acestea sunt doar cateva, multe dintre ele le-am rezolvat eu...

 

Edited by Alexandru Alex
Link to comment
Share on other sites

15 answers to this question

Recommended Posts

  • 0
42 minutes ago, Alexandru Alex said:

Salut SA-MP.RO, m-am apucat de un gamemode de la 0 si vreau sa fac un sistem de admin, am incercat unul dar nu este bun

CMD:setlevel(playerid, params[])
{
    new iD, Level, gMessage[250], gVictim[24];
    if(IsPlayerAdmin(playerid) == 1)
    {
        if(sscanf(params, "ui", iD, Level)) return SendClientMessage(playerid, 0xFF0000FF, "* Usage: /setlevel [playerid] [level]");
        else if(iD == playerid) return SendClientMessage(playerid, 0xFF0000FF, "* You cannot use that command on yourself");
        else if(!IsPlayerConnected(iD)) return SendClientMessage(playerid, 0xFF0000FF, "* That player is offline.");
        else
        {
            GetPlayerName(playerid, pName, sizeof(pName));
            GetPlayerName(iD, gVictim, sizeof(gVictim));
            format(gQuery, sizeof(gQuery), "UPDATE Users SET Admin = '%i' WHERE Name = '%s'", Level, pName);
            mysql_query(gQuery);
            
            format(gMessage, sizeof(gMessage), "* You have set %s an admin. Level: %i", gVictim, Level);
            SendClientMessage(playerid, 0xFFFFFFFF, gMessage);
            
            format(gMessage, sizeof(gMessage), "* You have been set as a level %i admin.", Level);
            SendClientMessage(playerid, 0xFFFFFFFF, gMessage);
            
            pInfo[iD][Admin] = Level;
        }
    }
    else
    {
        SendClientMessage(playerid, 0xFF0000FF, "* You are not an admin.");
    }
    return 1;
}

acest sistem este de pe net. dar imi da erori

error 035: argument type mismatch (argument 2)
error 039: constant symbol has no size
error 035: argument type mismatch (argument 1)
warning 215: expression has no effect
error 001: expected token: ";", but found "]"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line

si acestea sunt doar cateva, multe dintre ele le-am rezolvat eu...

 

Arata poza la linia care iti da erroare 

 Încearcă să fii un om de valoare și nu neapărat un om de succes.

 

Link to comment
Share on other sites

  • 0
19 minutes ago, KB.HERO said:

Arata linia la care iti da erroarea :) 

Nu mai am treba cu acel sistem, l-am schimbat dar problema este cand incerc sa dau admin altuia imi zice ca Acel player nu are admin

CMD:setadmin(playerid, params[])
{
	new
	    userID,
		lvl,
		szString[256],
		szQuery[256];

	if(PlayerInfo[playerid][pAdmin] < 6 && !Scripter(playerid)) return adminOnly(playerid);
	if(sscanf(params, "ui", userID, lvl)) return SendClientMessage(playerid, COLOR_GREY, "Syntax: {FFFFFF}/setadmin <playerid> <admin level>");
	if(!IsPlayerConnected(userID)) return NotLogged(playerid);
	if(lvl < 0 || lvl > 6) {
	 	SendClientMessage(playerid, COLOR_SERVER, "Error: {FFFFFF}Nivelul de admin trebuie sa fie cuprins intre {F51616}0{FFFFFF} si {F51616}6{FFFFFF}.");
		return 1;
	}
	if(PlayerInfo[userID][pAdmin] > PlayerInfo[playerid][pAdmin]) {
	 	SendClientMessage(playerid, COLOR_SERVER, "Eroare: {FFFFFF}Acel player are admin-ul mai mare decat tine.");
		return 1;
	}
	if(PlayerInfo[playerid][pAdmin] == 5 && lvl >= 2) {
	 	SendClientMessage(playerid, COLOR_SERVER, "Eroare: {FFFFFF}Nu poti da admin mai mare.");
	}

	if(userID != INVALID_PLAYER_ID)
	{
		if(lvl == 0) {
			if(PlayerInfo[userID][pAdmin] == 0) {
			 	SendClientMessage(playerid, COLOR_SERVER, "Eroare: {FFFFFF}Acel player nu are admin.");
				return 1;
		 	}
		 	if(PlayerInfo[playerid][pLanguage] == 1) {
				format(szString, sizeof(szString), "[!]{FFFFFF} L-ai demis pe %s din functia de admin.", GetName(userID));
	            SendClientMessage(playerid, COLOR_RED, szString);
	        }
	        if(PlayerInfo[userID][pLanguage] == 1) {
	        	format(szString, sizeof(szString), "[!]{FFFFFF} Ai fost demis de la functia de admin de administratorul %s.", GetName(playerid));
	            SendClientMessage(userID, COLOR_RED, szString);
	        }
            PlayerInfo[userID][pAdmin] = 0;
			return 1;
		}
		if(PlayerInfo[playerid][pLanguage] == 1) {
			format(szString, sizeof(szString), "[!]{FFFFFF} L-ai promovat pe %s ca admin Level %d.", GetName(userID), lvl);
	        SendClientMessage(playerid, COLOR_RED, szString);
	    }
	    if(PlayerInfo[userID][pLanguage] == 1) {
			format(szString, sizeof(szString), "[!]{FFFFFF} Ai fost promovat ca admin Level %d de administratorul %s.", lvl, GetName(playerid));
	        SendClientMessage(userID, COLOR_RED, szString);
	    }

		PlayerInfo[userID][pAdmin] = lvl;
		format(szQuery, sizeof(szQuery), "UPDATE `users` SET `Admin`='%d' WHERE `Username`='%s'", PlayerInfo[userID][pAdmin], GetName(userID));
		mysql_query(SQL, szQuery);
	}
	return 1;
}

noua comanda

Edited by Alexandru Alex
Link to comment
Share on other sites

  • 0
7 minutes ago, Alexandru Alex said:

Nu mai am treba cu acel sistem, l-am schimbat dar problema este cand incerc sa dau admin altuia imi zice ca Acel player nu are admin

CMD:setadmin(playerid, params[])
{
	new
	    userID,
		lvl,
		szString[256],
		szQuery[256];

	if(PlayerInfo[playerid][pAdmin] < 6 && !Scripter(playerid)) return adminOnly(playerid);
	if(sscanf(params, "ui", userID, lvl)) return SendClientMessage(playerid, COLOR_GREY, "Syntax: {FFFFFF}/setadmin <playerid> <admin level>");
	if(!IsPlayerConnected(userID)) return NotLogged(playerid);
	if(lvl < 0 || lvl > 6) {
	 	SendClientMessage(playerid, COLOR_SERVER, "Error: {FFFFFF}Nivelul de admin trebuie sa fie cuprins intre {F51616}0{FFFFFF} si {F51616}6{FFFFFF}.");
		return 1;
	}
	if(PlayerInfo[userID][pAdmin] > PlayerInfo[playerid][pAdmin]) {
	 	SendClientMessage(playerid, COLOR_SERVER, "Eroare: {FFFFFF}Acel player are admin-ul mai mare decat tine.");
		return 1;
	}
	if(PlayerInfo[playerid][pAdmin] == 5 && lvl >= 2) {
	 	SendClientMessage(playerid, COLOR_SERVER, "Eroare: {FFFFFF}Nu poti da admin mai mare.");
	}

	if(userID != INVALID_PLAYER_ID)
	{
		if(lvl == 0) {
			if(PlayerInfo[userID][pAdmin] == 0) {
			 	SendClientMessage(playerid, COLOR_SERVER, "Eroare: {FFFFFF}Acel player nu are admin.");
				return 1;
		 	}
		 	if(PlayerInfo[playerid][pLanguage] == 1) {
				format(szString, sizeof(szString), "[!]{FFFFFF} L-ai demis pe %s din functia de admin.", GetName(userID));
	            SendClientMessage(playerid, COLOR_RED, szString);
	        }
	        if(PlayerInfo[userID][pLanguage] == 1) {
	        	format(szString, sizeof(szString), "[!]{FFFFFF} Ai fost demis de la functia de admin de administratorul %s.", GetName(playerid));
	            SendClientMessage(userID, COLOR_RED, szString);
	        }
            PlayerInfo[userID][pAdmin] = 0;
			return 1;
		}
		if(PlayerInfo[playerid][pLanguage] == 1) {
			format(szString, sizeof(szString), "[!]{FFFFFF} L-ai promovat pe %s ca admin Level %d.", GetName(userID), lvl);
	        SendClientMessage(playerid, COLOR_RED, szString);
	    }
	    if(PlayerInfo[userID][pLanguage] == 1) {
			format(szString, sizeof(szString), "[!]{FFFFFF} Ai fost promovat ca admin Level %d de administratorul %s.", lvl, GetName(playerid));
	        SendClientMessage(userID, COLOR_RED, szString);
	    }

		PlayerInfo[userID][pAdmin] = lvl;
		format(szQuery, sizeof(szQuery), "UPDATE `users` SET `Admin`='%d' WHERE `Username`='%s'", PlayerInfo[userID][pAdmin], GetName(userID));
		mysql_query(SQL, szQuery);
	}
	return 1;
}

noua comanda

Quote

CMD:makeadmin(playerid, params[])
{
    if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "You need to log in first.");
    if(IsPlayerConnected(playerid))
    {
        if (PlayerInfo[playerid][pAdmin] >= 6 || EstiFondator(playerid))
        {
            new id,adminlevel,sendername[30],giveplayer[30],string[200],escape[200],str[500];
            if(sscanf(params, "ui",id,adminlevel)) return SendClientMessage(playerid, COLOR_GREY, "Syntax:{FFFFFF} /makeadmin [name/playerid] [level]");
            if(PlayerInfo[id][pAdmin] >= 6 && !EstiFondator(playerid)) return SendClientMessage(playerid, COLOR_WHITE, "You can't modify admin level to a admin 6+.");
            if(adminlevel < 0 || adminlevel > 6) return SCM(playerid, COLOR_WHITE, "Invalid level (0-6)");
            if(IsPlayerConnected(id))
            {
                if(id != INVALID_PLAYER_ID)
                {
                    GetPlayerName(id, giveplayer, sizeof(giveplayer));
                    GetPlayerName(playerid, sendername, sizeof(sendername));
                    if(PlayerInfo[id][pAdmin] < adminlevel)
                    {
                        format(string, sizeof(string), "You've been promoted to level %d admin, by %s.", adminlevel, sendername);
                        SendClientMessage(id, COLOR_YELLOW, string);
                        format(string, sizeof(string), "You've promoted %s to a level %d admin.", giveplayer, adminlevel);
                        SendClientMessage(playerid, COLOR_YELLOW, string);
                    }
                    else
                    {
                        format(string, sizeof(string), "You've been demoted to level %d admin, by %s.", adminlevel, sendername);
                        SendClientMessage(id, COLOR_YELLOW, string);
                        format(string, sizeof(string), "You've demoted %s to a level %d admin.", giveplayer, adminlevel);
                        SendClientMessage(playerid, COLOR_YELLOW, string);
                    }
                    format(string, sizeof(string), "* Admin %s set %s's admin level to %d.", sendername, giveplayer, adminlevel);
                    ABroadCast(COLOR_ADMCHAT,string,1);
                    Log(PlayerInfo[playerid][pSQLID], string, "staff");
                    mysql_real_escape_string(string, escape);
                    PlayerInfo[id][pAdmin] = adminlevel;
                    mysql_format(SQL,str,sizeof(str),"UPDATE users SET `Admin`='%d' WHERE `name`='%s'", PlayerInfo[id][pAdmin], PlayerInfo[id][pNormalName]);
                    mysql_tquery(SQL,str,"","");
                    new var100[256];
                    mysql_format(SQL, var100, sizeof(var100), "INSERT INTO playerlogs (`playerid`,`giverid`,`action`) VALUES ('%d','%d','%s')", PlayerInfo[id][pSQLID], PlayerInfo[playerid][pSQLID], escape);
                    mysql_tquery(SQL,var100,"","");
                    CheckPlayerLogs(id);
                    mysql_format(SQL,str, sizeof(str), "INSERT INTO staff_logs (`text`) VALUES ('%s')", escape);
                    mysql_tquery(SQL,str,"","");
                    if(adminlevel == 0)
                    {
                        PlayerInfo[id][pColors] = 0;
                        Update(id, pColorsx);
                    }
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "Player not connected.");
            }
        }
        else
        {
            SendClientMessage(playerid, -1, AdminOnly);
        }
    }
    return 1;
}

 

 Încearcă să fii un om de valoare și nu neapărat un om de succes.

 

Link to comment
Share on other sites

  • 0
5 minutes ago, KB.HERO said:

 

C:\Users\flowg\OneDrive\Desktop\rpg.new-server.ro\gamemodes\FirstOne.pwn(815) : error 017: undefined symbol "ABroadCast"
C:\Users\flowg\OneDrive\Desktop\rpg.new-server.ro\gamemodes\FirstOne.pwn(816) : error 017: undefined symbol "Log"
C:\Users\flowg\OneDrive\Desktop\rpg.new-server.ro\gamemodes\FirstOne.pwn(824) : error 017: undefined symbol "CheckPlayerLogs"
C:\Users\flowg\OneDrive\Desktop\rpg.new-server.ro\gamemodes\FirstOne.pwn(829) : error 017: undefined symbol "pColors"
C:\Users\flowg\OneDrive\Desktop\rpg.new-server.ro\gamemodes\FirstOne.pwn(829) : warning 215: expression has no effect
C:\Users\flowg\OneDrive\Desktop\rpg.new-server.ro\gamemodes\FirstOne.pwn(830) : error 017: undefined symbol "pColorsx"

erorile

Link to comment
Share on other sites

  • 0

In loc de ABroadCast , foloseste functia 'SendAdminMessage' , e acelasi lucru.

 

Citat

function SendAdminMessage(color,const string[],level) {
    new text[180];
    foreach(Player, i) {
        if(IsPlayerConnected(i) && IsPlayerLogged == 1) {
            if(IsPlayerLogged == 1) {
                if(PlayerInfo[pAdmin] >= level) {
                    format(text, 256, string);
                    SendClientMessage(i, color, text);                
                }
            }
        }
    }
    printf("%s", string);
    return 1;
}

 

Iar acolo in loc de 'ABroadCast(COLOR_ADMCHAT,string,1);' , scrii ' SendAdminMessage(COLOR_LIGHTRED, string, 1); '

 

 

La restul este problema ca nu corespund functiile din gamemode ul de pe care a fost luata comanda cu al tau gamemode , trebuie sa schimbi functiile cu functiile gamemode-ului tau.

 

De obicei 'pColorsx' se defineste in fisierul '.inc' , gen se foloseste la salvarea in baza de date.

 

Exemplu :

Citat

case pCashx: format(var, sizeof(var), "UPDATE `users` SET `Money`='%d' WHERE `ID`='%d'",GetPlayerCash(playerid), PlayerInfo[playerid][pSQLID]);

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.