PDA

View Full Version : [HELP]: /makeadmin


Areax
24/10/2013, 04:47 PM
Hello SA-MP !

I have another problem. Well, i made a /makeadmin command, which basicly sets the player's admin level. But the problem is, message that a player has been promoted/demoted don't show :/

Code:

CMD:makeadmin(playerid, params[])
{
new string[200];
new str[200];
new targetid;
new level;
if(pInfo[playerid][Adminlevel] < 10)return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}You need to be {FF0000}Admin Level 10{FFFFFF}, to use this command !");
if(sscanf(params, "ui", targetid, level))return SendClientMessage(playerid, GREY, "[USAGE]: /makeadmin {FF0000}[PlayerID] [Level]");
if(!IsPlayerConnected(targetid))return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}This player is {FF0000}NOT {FFFFFF}connected !");
if(level < 0 || level > 10)return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}Invalid Admin Level {FF0000}(0 - 10) {FFFFFF}!");
if(pInfo[targetid][Adminlevel] == level)return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}This player {FF0000}already {FFFFFF}has this Admin Level !");
if(pInfo[targetid][Adminlevel] < level)
{
format(string, sizeof(string), "[SERVER]: {FFFFFF}Player {FF8000}%s(ID:%d) {FFFFFF}has been {FF8000}promoted {FFFFFF}by an Admin {FF8000}%s(ID:%d) {FFFFFF}to level {FF0000}%d {FFFFFF}!", GetName(targetid), targetid, GetName(playerid), playerid, level);
GameTextForPlayer(targetid, "~g~ PROMOTED !", 3000, 6);
SendClientMessageToAll(GREEN, string);
pInfo[targetid][Adminlevel] = level;
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file, "Player's Data");
INI_WriteInt(file, "AdminLevel", pInfo[targetid][Adminlevel]);
}
if(pInfo[targetid][Adminlevel] > level)
{
format(str, sizeof(str), "[SERVER]: {FFFFFF}Player {FF8000}%s(ID:%d) {FFFFFF}has been {FF8000}demoted {FFFFFF}by an Admin {FF8000}%s(ID:%d) {FFFFFF}to level {FF0000}%d {FFFFFF}!", GetName(targetid), targetid, GetName(playerid), playerid, level);
GameTextForPlayer(targetid, "~g~ DEMOTED !", 3000, 6);
SendClientMessageToAll(GREEN, str);
pInfo[targetid][Adminlevel] = level;
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file, "Player's Data");
INI_WriteInt(file, "AdminLevel", pInfo[targetid][Adminlevel]);
}
return 1;
}

Thanks

damian123
24/10/2013, 05:10 PM
Does it make the player an admin, though?

Areax
24/10/2013, 05:12 PM
it is, it also send a Game Text. btw, it doesn't send a client message.

damian123
24/10/2013, 05:17 PM
Try this:CMD:makeadmin(playerid, params[])
{
new string[256];
new str[256];
new targetid;
new level;
if(pInfo[playerid][Adminlevel] < 10)return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}You need to be {FF0000}Admin Level 10{FFFFFF}, to use this command !");
if(sscanf(params, "ui", targetid, level))return SendClientMessage(playerid, GREY, "[USAGE]: /makeadmin {FF0000}[PlayerID] [Level]");
if(!IsPlayerConnected(targetid))return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}This player is {FF0000}NOT {FFFFFF}connected !");
if(level < 0 || level > 10)return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}Invalid Admin Level {FF0000}(0 - 10) {FFFFFF}!");
if(pInfo[targetid][Adminlevel] == level)return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}This player {FF0000}already {FFFFFF}has this Admin Level !");
if(pInfo[targetid][Adminlevel] < level)
{
format(string, sizeof(string), "[SERVER]: {FFFFFF}Player {FF8000}%s(ID:%d) {FFFFFF}has been {FF8000}promoted {FFFFFF}by an Admin {FF8000}%s(ID:%d) {FFFFFF}to level {FF0000}%d {FFFFFF}!", GetName(targetid), targetid, GetName(playerid), playerid, level);
SendClientMessageToAll(GREEN, string);
GameTextForPlayer(targetid, "~g~ PROMOTED !", 3000, 6);
pInfo[targetid][Adminlevel] = level;
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file, "Player's Data");
INI_WriteInt(file, "AdminLevel", pInfo[targetid][Adminlevel]);
return 1;
}
if(pInfo[targetid][Adminlevel] > level)
{
format(str, sizeof(str), "[SERVER]: {FFFFFF}Player {FF8000}%s(ID:%d) {FFFFFF}has been {FF8000}demoted {FFFFFF}by an Admin {FF8000}%s(ID:%d) {FFFFFF}to level {FF0000}%d {FFFFFF}!", GetName(targetid), targetid, GetName(playerid), playerid, level);
SendClientMessageToAll(GREEN, str);
GameTextForPlayer(targetid, "~g~ DEMOTED !", 3000, 6);
pInfo[targetid][Adminlevel] = level;
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file, "Player's Data");
INI_WriteInt(file, "AdminLevel", pInfo[targetid][Adminlevel]);
return 1;
}
return 1;
}EDIT: Sorry, forgot the returns.

Tomix
24/10/2013, 05:21 PM
Try this
CMD:makeadmin(playerid,params[])
{
if(pInfo[playerid][AdminLevel] < 6 || IsPlayerAdmin(playerid))
{
new targetid,level,string[180];
if(sscanf(params, "ud", targetid, level)) return SendClientMessage(playerid,-1,""chat" /setadmin [playerid] [level]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1,""chat" Player is not online");
if(level < 0 || level > 6) return SendClientMessage(playerid,-1,""chat" Admin levels are ONLY between 1-6");

pInfo[targetid][AdminLevel] = level;

format(string, sizeof(string), "*"COL_RED" %s %s have given admin status of %d to %s",GetAdminName(playerid),PlayerName(playerid),level ,PlayerName(targetid));
SendClientMessageToAll(-1,string);
}
else {
SendClientMessage(playerid,-1,"*"COL_RED" You do not have the right admin permissions for this command!");
}
return 1;
}
or
CMD:makeadmin(playerid,params[])
{
if(pInfo[playerid][AdminLevel] >= 6 || IsPlayerAdmin(playerid))
{
new targetid,level,string[180];
if(sscanf(params, "ud", targetid, level)) return SendClientMessage(playerid,-1,""chat" /setadmin [playerid] [level]");
if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid,-1,""chat" Player is not online");
if(level < 0 || level > 6) return SendClientMessage(playerid,-1,""chat" Admin levels are ONLY between 1-6");

pInfo[targetid][AdminLevel] = level;

format(string, sizeof(string), "*"COL_RED" %s %s have given admin status of %d to %s",GetAdminName(playerid),PlayerName(playerid),level ,PlayerName(targetid));
SendClientMessageToAll(-1,string);
}
else {
SendClientMessage(playerid,-1,"*"COL_RED" You do not have the right admin permissions for this command!");
}
return 1;
}

Areax
24/10/2013, 05:22 PM
Don't work still.

damian123
24/10/2013, 05:24 PM
Did you see my new edit? Because SendClientMessageToAll always returns 1.

Tomix
24/10/2013, 05:25 PM
Are you getting any errors?
I have also re-edited my cmds

Areax
24/10/2013, 05:28 PM
Still don't work and no errors.

damian123
24/10/2013, 05:29 PM
Do you have any example of a Message that is sent to All?

Tomix
24/10/2013, 05:29 PM
Well what actually happens when you type in the cmd?

Areax
24/10/2013, 05:32 PM
you mean like
CMD:test(playerid, params[])
{
SendClientMessageToAll(playerid, -1, "Works !");
return 1;
}

Parka
24/10/2013, 05:33 PM
Testing


CMD:makeadmin(playerid, params[]){
new string[200];
new str[200];
new targetid;
new level;
if(pInfo[playerid][Adminlevel] < 10)return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}You need to be {FF0000}Admin Level 10{FFFFFF}, to use this command !");
if(sscanf(params, "ui", targetid, level))return SendClientMessage(playerid, GREY, "[USAGE]: /makeadmin {FF0000}[PlayerID] [Level]");
if(!IsPlayerConnected(targetid))return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}This player is {FF0000}NOT {FFFFFF}connected !");
if(level < 0 || level > 10)return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}Invalid Admin Level {FF0000}(0 - 10) {FFFFFF}!");
if(pInfo[targetid][Adminlevel] == level)return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}This player {FF0000}already {FFFFFF}has this Admin Level !");

if(pInfo[targetid][Adminlevel] < level){
GameTextForPlayer(playerid,"~g~~h~PROMOTED!",3000,6);
}else{
GameTextForPlayer(playerid,"~r~DEMOTED!",3000,6);}

pInfo[targetid][Adminlevel] = level;
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file, "Player's Data");
INI_WriteInt(file, "AdminLevel",pInfo[targetid][Adminlevel]);
format(str, sizeof(str), "[SERVER]: {FFFFFF}Player {FF8000}%s(ID:%d) {FFFFFF}has been {FF8000}demoted {FFFFFF}by an Admin {FF8000}%s(ID:%d) {FFFFFF}to level {FF0000}%d {FFFFFF}!", GetName(targetid), targetid, GetName(playerid), playerid, level);
SendClientMessageToAll(GREEN, str);
return 1;
}

Areax
24/10/2013, 05:38 PM
Testing


CMD:makeadmin(playerid, params[]){
new string[200];
new str[200];
new targetid;
new level;
if(pInfo[playerid][Adminlevel] < 10)return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}You need to be {FF0000}Admin Level 10{FFFFFF}, to use this command !");
if(sscanf(params, "ui", targetid, level))return SendClientMessage(playerid, GREY, "[USAGE]: /makeadmin {FF0000}[PlayerID] [Level]");
if(!IsPlayerConnected(targetid))return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}This player is {FF0000}NOT {FFFFFF}connected !");
if(level < 0 || level > 10)return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}Invalid Admin Level {FF0000}(0 - 10) {FFFFFF}!");
if(pInfo[targetid][Adminlevel] == level)return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}This player {FF0000}already {FFFFFF}has this Admin Level !");

if(pInfo[targetid][Adminlevel] < level){
GameTextForPlayer(playerid,"~g~~h~PROMOTED!",3000,6);
}else{
GameTextForPlayer(playerid,"~r~DEMOTED!",3000,6);}

pInfo[targetid][Adminlevel] = level;
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file, "Player's Data");
INI_WriteInt(file, "AdminLevel",pInfo[targetid][Adminlevel]);
format(str, sizeof(str), "[SERVER]: {FFFFFF}Player {FF8000}%s(ID:%d) {FFFFFF}has been {FF8000}demoted {FFFFFF}by an Admin {FF8000}%s(ID:%d) {FFFFFF}to level {FF0000}%d {FFFFFF}!", GetName(targetid), targetid, GetName(playerid), playerid, level);
SendClientMessageToAll(GREEN, str);
return 1;
}


Doesn't send the message either

xVIP3Rx
24/10/2013, 05:44 PM
CMD:makeadmin(playerid, params[])
{
new string[200];
new str[200];
new targetid;
new level;
if(pInfo[playerid][Adminlevel] < 10)return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}You need to be {FF0000}Admin Level 10{FFFFFF}, to use this command !");
if(sscanf(params, "ui", targetid, level))return SendClientMessage(playerid, GREY, "[USAGE]: /makeadmin {FF0000}[PlayerID] [Level]");
if(!IsPlayerConnected(targetid))return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}This player is {FF0000}NOT {FFFFFF}connected !");
if(level < 0 || level > 10)return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}Invalid Admin Level {FF0000}(0 - 10) {FFFFFF}!");
if(pInfo[targetid][Adminlevel] == level)return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}This player {FF0000}already {FFFFFF}has this Admin Level !");
if(pInfo[targetid][Adminlevel] < level)
{
format(string, sizeof(string), "[SERVER]: {FFFFFF}Player {FF8000}%s(ID:%d) {FFFFFF}has been {FF8000}promoted {FFFFFF}by an Admin {FF8000}%s(ID:%d) {FFFFFF}to level {FF0000}%d {FFFFFF}!", GetName(targetid), targetid, GetName(playerid), playerid, level);
print(string);
GameTextForPlayer(targetid, "~g~ PROMOTED !", 3000, 6);
SendClientMessageToAll(GREEN, string);
pInfo[targetid][Adminlevel] = level;
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file, "Player's Data");
INI_WriteInt(file, "AdminLevel", pInfo[targetid][Adminlevel]);
}
if(pInfo[targetid][Adminlevel] > level)
{
format(str, sizeof(str), "[SERVER]: {FFFFFF}Player {FF8000}%s(ID:%d) {FFFFFF}has been {FF8000}demoted {FFFFFF}by an Admin {FF8000}%s(ID:%d) {FFFFFF}to level {FF0000}%d {FFFFFF}!", GetName(targetid), targetid, GetName(playerid), playerid, level);
print(str);
GameTextForPlayer(targetid, "~g~ DEMOTED !", 3000, 6);
SendClientMessageToAll(GREEN, str);
pInfo[targetid][Adminlevel] = level;
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file, "Player's Data");
INI_WriteInt(file, "AdminLevel", pInfo[targetid][Adminlevel]);
}
return 1;
}

Tell me if you got a message on the server console.

damian123
24/10/2013, 05:48 PM
you mean like
CMD:test(playerid, params[])
{
SendClientMessageToAll(playerid, -1, "Works !");
return 1;
}SenclientMessageToAll doesn't need "playerid", lol
Just search for a line using SendClientMessageToAll and paste it here

Areax
24/10/2013, 05:50 PM
CMD:makeadmin(playerid, params[])
{
new string[200];
new str[200];
new targetid;
new level;
if(pInfo[playerid][Adminlevel] < 10)return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}You need to be {FF0000}Admin Level 10{FFFFFF}, to use this command !");
if(sscanf(params, "ui", targetid, level))return SendClientMessage(playerid, GREY, "[USAGE]: /makeadmin {FF0000}[PlayerID] [Level]");
if(!IsPlayerConnected(targetid))return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}This player is {FF0000}NOT {FFFFFF}connected !");
if(level < 0 || level > 10)return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}Invalid Admin Level {FF0000}(0 - 10) {FFFFFF}!");
if(pInfo[targetid][Adminlevel] == level)return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}This player {FF0000}already {FFFFFF}has this Admin Level !");
if(pInfo[targetid][Adminlevel] < level)
{
format(string, sizeof(string), "[SERVER]: {FFFFFF}Player {FF8000}%s(ID:%d) {FFFFFF}has been {FF8000}promoted {FFFFFF}by an Admin {FF8000}%s(ID:%d) {FFFFFF}to level {FF0000}%d {FFFFFF}!", GetName(targetid), targetid, GetName(playerid), playerid, level);
print(string);
GameTextForPlayer(targetid, "~g~ PROMOTED !", 3000, 6);
SendClientMessageToAll(GREEN, string);
pInfo[targetid][Adminlevel] = level;
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file, "Player's Data");
INI_WriteInt(file, "AdminLevel", pInfo[targetid][Adminlevel]);
}
if(pInfo[targetid][Adminlevel] > level)
{
format(str, sizeof(str), "[SERVER]: {FFFFFF}Player {FF8000}%s(ID:%d) {FFFFFF}has been {FF8000}demoted {FFFFFF}by an Admin {FF8000}%s(ID:%d) {FFFFFF}to level {FF0000}%d {FFFFFF}!", GetName(targetid), targetid, GetName(playerid), playerid, level);
print(str);
GameTextForPlayer(targetid, "~g~ DEMOTED !", 3000, 6);
SendClientMessageToAll(GREEN, str);
pInfo[targetid][Adminlevel] = level;
new INI:file = INI_Open(Path(playerid));
INI_SetTag(file, "Player's Data");
INI_WriteInt(file, "AdminLevel", pInfo[targetid][Adminlevel]);
}
return 1;
}

Tell me if you got a message on the server console.

On the console it is the message.

damian123
24/10/2013, 05:53 PM
Do you use any kind of formation like SendClientMessageToAllEx? Just search for a line using SendClientMessageToAll and paste it here, please.

xVIP3Rx
24/10/2013, 05:54 PM
Is SendClientMessageToAll working on any other cmd/function ?
And replace GREEN with -1

Areax
24/10/2013, 05:54 PM
@damian123
Nothing.

Areax
24/10/2013, 05:59 PM
CMD:test(playerid, params[])
{
SendClientMessageToAll(GREEN, "Working !");
return 1;
}

Tried this and it works .

Patrick
24/10/2013, 06:27 PM
Why would you like to Write instead of creating them when the player is registering, and just set the variable to 0.


CMD:makeadmin(playerid, params[])
{
new
string[200],
targetid,
level
;

if(pInfo[playerid][Adminlevel] < 10)
return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}You need to be {FF0000}Admin Level 10{FFFFFF}, to use this command !");

if(sscanf(params, "ui", targetid, level))
return SendClientMessage(playerid, GREY, "[USAGE]: /makeadmin {FF0000}[PlayerID] [Level]");
if(!IsPlayerConnected(targetid))
return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}This player is {FF0000}NOT {FFFFFF}connected !");

if(0 <= level <= 10)
return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}Invalid Admin Level {FF0000}(0 - 10) {FFFFFF}!");

if(pInfo[targetid][Adminlevel] == level)
return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}This player {FF0000}already {FFFFFF}has this Admin Level !");

if(pInfo[targetid][Adminlevel] <= level)
{
format(string, sizeof(string), "[SERVER]: {FFFFFF}Player {FF8000}%s(ID:%d) {FFFFFF}has been {FF8000}promoted {FFFFFF}by an Admin {FF8000}%s(ID:%d) {FFFFFF}to level {FF0000}%d {FFFFFF}!", GetName(targetid), targetid, GetName(playerid), playerid, level);
GameTextForPlayer(targetid, "~g~ PROMOTED !", 3000, 6);
SendClientMessageToAll(GREEN, string);
}
if(pInfo[targetid][Adminlevel] >= level)
{
format(string, sizeof(string), "[SERVER]: {FFFFFF}Player {FF8000}%s(ID:%d) {FFFFFF}has been {FF8000}demoted {FFFFFF}by an Admin {FF8000}%s(ID:%d) {FFFFFF}to level {FF0000}%d {FFFFFF}!", GetName(targetid), targetid, GetName(playerid), playerid, level);
GameTextForPlayer(targetid, "~g~ DEMOTED !", 3000, 6);
SendClientMessageToAll(GREEN, string);
}
pInfo[targetid][Adminlevel] = level;
//You should have something like this SaveUser(playerid); or SaveAccount(playerid);

/*new INI:file = INI_Open(Path(playerid));
INI_SetTag(file, "Player's Data");
INI_WriteInt(file, "AdminLevel", pInfo[targetid][Adminlevel]);*/
return 1;
}

Areax
25/10/2013, 01:38 PM
Why would you like to Write instead of creating them when the player is registering, and just set the variable to 0.


CMD:makeadmin(playerid, params[])
{
new
string[200],
targetid,
level
;

if(pInfo[playerid][Adminlevel] < 10)
return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}You need to be {FF0000}Admin Level 10{FFFFFF}, to use this command !");

if(sscanf(params, "ui", targetid, level))
return SendClientMessage(playerid, GREY, "[USAGE]: /makeadmin {FF0000}[PlayerID] [Level]");
if(!IsPlayerConnected(targetid))
return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}This player is {FF0000}NOT {FFFFFF}connected !");

if(0 <= level <= 10)
return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}Invalid Admin Level {FF0000}(0 - 10) {FFFFFF}!");

if(pInfo[targetid][Adminlevel] == level)
return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}This player {FF0000}already {FFFFFF}has this Admin Level !");

if(pInfo[targetid][Adminlevel] <= level)
{
format(string, sizeof(string), "[SERVER]: {FFFFFF}Player {FF8000}%s(ID:%d) {FFFFFF}has been {FF8000}promoted {FFFFFF}by an Admin {FF8000}%s(ID:%d) {FFFFFF}to level {FF0000}%d {FFFFFF}!", GetName(targetid), targetid, GetName(playerid), playerid, level);
GameTextForPlayer(targetid, "~g~ PROMOTED !", 3000, 6);
SendClientMessageToAll(GREEN, string);
}
if(pInfo[targetid][Adminlevel] >= level)
{
format(string, sizeof(string), "[SERVER]: {FFFFFF}Player {FF8000}%s(ID:%d) {FFFFFF}has been {FF8000}demoted {FFFFFF}by an Admin {FF8000}%s(ID:%d) {FFFFFF}to level {FF0000}%d {FFFFFF}!", GetName(targetid), targetid, GetName(playerid), playerid, level);
GameTextForPlayer(targetid, "~g~ DEMOTED !", 3000, 6);
SendClientMessageToAll(GREEN, string);
}
pInfo[targetid][Adminlevel] = level;
//You should have something like this SaveUser(playerid); or SaveAccount(playerid);

/*new INI:file = INI_Open(Path(playerid));
INI_SetTag(file, "Player's Data");
INI_WriteInt(file, "AdminLevel", pInfo[targetid][Adminlevel]);*/
return 1;
}


This code still doesn't send the message.

Patrick
25/10/2013, 01:41 PM
This code still doesn't send the message.

Can you be more specific, what message doesn't show?

Areax
25/10/2013, 01:51 PM
If the player is promoted should send this
format(string, sizeof(string), "[SERVER]: {FFFFFF}Player {FF8000}%s(ID:%d) {FFFFFF}has been {FF8000}promoted {FFFFFF}by an Admin {FF8000}%s(ID:%d) {FFFFFF}to level {FF0000}%d {FFFFFF}!", GetName(targetid), targetid, GetName(playerid), playerid, level);
Or if demoted this
format(string, sizeof(string), "[SERVER]: {FFFFFF}Player {FF8000}%s(ID:%d) {FFFFFF}has been {FF8000}demoted {FFFFFF}by an Admin {FF8000}%s(ID:%d) {FFFFFF}to level {FF0000}%d {FFFFFF}!", GetName(targetid), targetid, GetName(playerid), playerid, level);

Patrick
25/10/2013, 01:56 PM
I guess I just did a mistake, I forgot to put else on the statement

Here you go

CMD:makeadmin(playerid, params[])
{
new
string[200],
targetid,
level
;

if(pInfo[playerid][Adminlevel] < 10)
return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}You need to be {FF0000}Admin Level 10{FFFFFF}, to use this command !");

if(sscanf(params, "ui", targetid, level))
return SendClientMessage(playerid, GREY, "[USAGE]: /makeadmin {FF0000}[PlayerID] [Level]");
if(!IsPlayerConnected(targetid))
return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}This player is {FF0000}NOT {FFFFFF}connected !");

if(0 <= level <= 10)
return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}Invalid Admin Level {FF0000}(0 - 10) {FFFFFF}!");

if(pInfo[targetid][Adminlevel] == level)
return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}This player {FF0000}already {FFFFFF}has this Admin Level !");

if(pInfo[targetid][Adminlevel] <= level)
{
format(string, sizeof(string), "[SERVER]: {FFFFFF}Player {FF8000}%s(ID:%d) {FFFFFF}has been {FF8000}promoted {FFFFFF}by an Admin {FF8000}%s(ID:%d) {FFFFFF}to level {FF0000}%d {FFFFFF}!", GetName(targetid), targetid, GetName(playerid), playerid, level);
GameTextForPlayer(targetid, "~g~ PROMOTED !", 3000, 6);
}
else if(pInfo[targetid][Adminlevel] >= level)
{
format(string, sizeof(string), "[SERVER]: {FFFFFF}Player {FF8000}%s(ID:%d) {FFFFFF}has been {FF8000}demoted {FFFFFF}by an Admin {FF8000}%s(ID:%d) {FFFFFF}to level {FF0000}%d {FFFFFF}!", GetName(targetid), targetid, GetName(playerid), playerid, level);
GameTextForPlayer(targetid, "~g~ DEMOTED !", 3000, 6);
}
SendClientMessageToAll(GREEN, string);
pInfo[targetid][Adminlevel] = level;
return 1;
}

Areax
25/10/2013, 02:02 PM
Nope, doesn't send

rickisme
25/10/2013, 02:03 PM
CMD:makeadmin(playerid, params[])
{
new string[200],
targetid,
level;

if(pInfo[playerid][Adminlevel] < 10)return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}You need to be {FF0000}Admin Level 10{FFFFFF}, to use this command !");
if(sscanf(params, "ui", targetid, level))return SendClientMessage(playerid, GREY, "[USAGE]: /makeadmin {FF0000}[PlayerID] [Level]");
if(!IsPlayerConnected(targetid))return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}This player is {FF0000}NOT {FFFFFF}connected !");
if(level < 0 || level > 10)return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}Invalid Admin Level {FF0000}(0 - 10) {FFFFFF}!");
if(pInfo[targetid][Adminlevel] == level)return SendClientMessage(playerid, RED, "[SERVER]: {FFFFFF}This player {FF0000}already {FFFFFF}has this Admin Level !");
if(pInfo[targetid][Adminlevel] < level)
{
format(string, sizeof(string), "[SERVER] %s(%d) PROMOTED %s(%d) to AdminLevel %i", GetName(playerid), playerid, GetName(targetid), targetid, level);
GameTextForPlayer(targetid, "~g~ PROMOTED !", 3000, 6);
}
else
{
format(string, sizeof(string), "[SERVER] %s(%d) DEMOTED %s(%d) to AdminLevel %i", GetName(playerid), playerid, GetName(targetid), targetid, level);
GameTextForPlayer(targetid, "~g~ DEMOTED !", 3000, 6);
}

SendClientMessageToAll(GREEN, string);
/* if not work try :
foreach(Player, i)
{
SendClientMessage(i, GREEN, string);
}
*/
pInfo[targetid][Adminlevel] = level;
new INI:file = INI_Open(Path(targetid));
INI_SetTag(file, "Player's Data");
INI_WriteInt(file, "AdminLevel", pInfo[targetid][Adminlevel]);
return 1;
}

Rydur
25/10/2013, 02:25 PM
This should work, its currently working for my server.


CMD:makeadmin(playerid, params[]) {
if(PlayerInfo[playerid][pAdmin] >= 99999) {

new
iAdminValue,
iTargetID;

if(sscanf(params, "ui", iTargetID, iAdminValue)) {
SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /makeadmin [playerid] [level]");
}
else if(IsPlayerConnected(iTargetID)) {
if(PlayerInfo[iTargetID][pHelper] >= 1) {
SendClientMessageEx(playerid, COLOR_GRAD1, "You cannot make Community Helpers admins!");
}
else {

new
szMessage[47 + (MAX_PLAYER_NAME * 2)];

PlayerInfo[iTargetID][pAdmin] = iAdminValue;
format(szMessage, sizeof(szMessage), "{33AA33}AdmCmd: %s{AA3333} has promoted %s to a level %d admin.", GetPlayerNameEx(playerid), GetPlayerNameEx(iTargetID), iAdminValue);
ABroadCast(COLOR_LIGHTRED,szMessage, 2);
format(szMessage, sizeof(szMessage), "You have been promoted to a level %d admin by %s.", iAdminValue, GetPlayerNameEx(playerid));
SendClientMessageEx(iTargetID, COLOR_LIGHTBLUE, szMessage);
format(szMessage, sizeof(szMessage), "You have promoted %s to a level %d admin.", GetPlayerNameEx(iTargetID),iAdminValue);
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, szMessage);
}
}
else SendClientMessageEx(playerid, COLOR_GRAD2, "Invalid player specified.");
}
else SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
return 1;
}

Areax
25/10/2013, 02:26 PM
Well, now i know.. SendClientMessageToAll can't send that much text, maybe. That's why it didn't send it.

Konstantinos
25/10/2013, 02:40 PM
Well, now i know.. SendClientMessageToAll can't send that much text, maybe. That's why it didn't send it.

It can display 144 characters.

Areax
25/10/2013, 02:41 PM
It can display 144 characters.

-.- Not enough.

Konstantinos
25/10/2013, 02:48 PM
True, remove the color embedding from the text and it's pretty much 140 characters.


"[SERVER]: Player %s(ID:%d) has been promoted by an Admin %s(ID:%d) to level %d!"


If it does not display the message, then there's something else wrong with it.

Areax
25/10/2013, 02:56 PM
It display, but i would like to have colors :/