Admin Duty
#1

Код:
CMD:adminduty(playerid)
{
    if(PlayerInfo[playerid][Level] >=1 || IsPlayerAdmin(playerid))
    {
        if (adminDuty[playerid] == 0)
        {
            new string[128];
            SetPlayerHealth(playerid,999999);
            SetPlayerColor(playerid,COLOUR_BLUE);
            SetPlayerSkin(playerid,294);
            format(string,sizeof(string), "%s is now on Duty!",GetPlayerName(playerid));
            SendClientMessageToAll(COLOUR_BLUE,string);
            SendClientMessage(playerid,COLOUR_BLUE,"You are now on duty!");
            adminDuty[playerid] = 1;
        }
        else if (adminDuty[playerid] == 1)
        {
            new string[128];
            SetPlayerHealth(playerid,100);
            format(string,sizeof(string)," %s is now off Duty!",GetPlayerName(playerid));
            SendClientMessageToAll(COLOUR_BLUE,string);
            SendClientMessage(playerid, COLOUR_BLUE,"You are now off duty!");
            adminDuty[playerid] = 0;
        }
    }
    else
        SendClientMessage(playerid,COLOUR_BLUE,"You're not an admin!");
    return 1;
}

stock GetPlayerNameEx(playerid) //This is stock i made to make Getting players name easier
{
	new Name[MAX_PLAYER_NAME];
	GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
	return Name;
}
copy from this

https://sampforum.blast.hk/showthread.php?tid=476571

help me

PHP код:
C:\Users\aiman\Desktop\Project\ADADA\LTFDM.pwn(20510) : warning 202number of arguments does not match definition
C
:\Users\aiman\Desktop\Project\ADADA\LTFDM.pwn(20510) : warning 202number of arguments does not match definition
C
:\Users\aiman\Desktop\Project\ADADA\LTFDM.pwn(20519) : warning 202number of arguments does not match definition
C
:\Users\aiman\Desktop\Project\ADADA\LTFDM.pwn(20519) : warning 202number of arguments does not match definition
Pawn compiler 3.2.3664              Copyright 
(c1997-2006ITB CompuPhase
4 Warnings

Reply
#2

And we're supposed to guess which lines has the warnings? please define which line is 20510 and 20519 .
Reply
#3

this one

Код:
            format(string,sizeof(string), "%s is now on Duty!",GetPlayerName(playerid));
and


Код:
            format(string,sizeof(string)," %s is now off Duty!",GetPlayerName(playerid));
Reply
#4

Lol, Replace GetPlayerName with the GetPlayerNameEx you made...
Reply
#5

Код:
CMD:aduty(playerid,params[]) //Doesnt need params function
{
	if(PlayerInfo[playerid][Level] >=1 || IsPlayerAdmin(playerid)) //If you use rcon admin delete (PlayerInfo[playerid][pAdmin] >=1 ||
	{
		if (adminDuty[playerid] == 0) //Check if player is on duty
		{
			new Float:x,Float:y,Float:z;
			new Text3D:label = Create3DTextLabel("Admin On Duty!", COLOR_RED,x,y,z, 40.0, 0, 0); //Creates 3d text label at player position
			GetPlayerPos(playerid,x,y,z); //Looks for players position
			SetPlayerHealth(playerid,100000); //makes player godmode
			SetPlayerColor(playerid,COLOR_RED); //set admin colour red
			SetPlayerSkin(playerid,217); //set admin skin to 294
			GivePlayerWeapon(playerid,38,0);
			new string[128]; format(string, sizeof(string), "{FF0000} %s is now on Duty!", PlayerName2(playerid), params[0] ); //here you format string to send to players
			SendClientMessageToAll(COLOR_RED,string); //send string to players
			SendClientMessage(playerid,COLOR_BLUE,"You are now on duty!"); //Tell admin he is now on duty
			Attach3DTextLabelToPlayer(label,playerid,0.0, 0.0, 0.7); //attach 3d text label made before to player
			adminDuty[playerid] = 1; //Set player on duty
		}
		else if (adminDuty[playerid] == 1) //Check if player is on duty
		{
  			new Float:x,Float:y,Float:z;
  			new Text3D:label = Create3DTextLabel("Admin On Duty!", COLOR_RED,x,y,z, 40.0, 0, 0);
  			Delete3DTextLabel(label); //Delete 3d text label saying "Admin On Duty!"
  			SetPlayerHealth(playerid,100); //sets player health back to 100
			new string[128]; format(string, sizeof(string), "{FF0000} %s is now off Duty!", PlayerName2(playerid), params[0] ); //Format string to send to players
			SendClientMessageToAll(COLOR_RED,string); //send players string
			SendClientMessage(playerid,COLOR_BLUE,"You are now off duty!"); //send admin message he is off duty
			adminDuty[playerid] = 0; //sets admin off duty
			ForceClassSelection(playerid);
			SetPlayerHealth(playerid, 0);
		}
 	}
	else
		SendClientMessage(playerid,COLOR_RED,"You are not high level enough!"); //Error message to send to players who arent admins
	return 1;
}
done,but how to make this

when admin duty on,and admin use /kill

they will spawn with Default skin?

how to make they spawn with admin duty skin ( when admin duty on )?
Reply
#6

Replace with this, for having more space of your script and more understandable.
Код:
CMD:adminduty(playerid)
{
    if(!PlayerInfo[playerid][Level] && !IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOUR_BLUE, "You're not an admin!");
    static str[64];
    adminDuty[playerid] = !adminDuty[playerid];
    SetPlayerHealth(playerid, adminDuty[playerid] ? 9999 : 100);
    SetPlayerColor(playerid, COLOUR_BLUE);
    SetPlayerSkin(playerid, 294);

    format(string, sizeof(string), "%s is now %s Duty!", GetPlayerNameEx(playerid), adminDuty[playerid] ? "on" : "off");
    SendClientMessageToAll(COLOUR_BLUE, string);
    format(string, sizeof(string), "You are now %s duty!", adminDuty[playerid] ? "on" : "off");
    SendClientMessage(playerid, COLOUR_BLUE, string);
    return 1;
}
There are some issues I fixed for you.

if(PlayerInfo[playerid][Level] >=1 || IsPlayerAdmin(playerid)) You are determing a player if they are admin OR level >= 1, for pLevel, just using PlayerInfo[playerid][Level] to check if they are set

The rest coding you should use conditional operator to do that for less code, and more performance.

Код:
adminDuty[playerid] ? 9999 : 100 // returns a Boolean

=

if(AdminDuty[playerid] == true)
{
     SetPlayerHealth(playerid, 9999);
} else {
     SetPlayerHealth(playerid, 100);
}
Reply
#7

PHP код:
CMD:adminduty(playeridparams[])
{
    if(!
PlayerInfo[playerid][Level] && !IsPlayerAdmin(playerid)) return SendClientMessage(playeridCOLOUR_BLUE"You're not an admin!");
    
adminDuty[playerid] = !adminDuty[playerid];
    
SetPlayerHealth(playeridadminDuty[playerid] ? 9999.0 100.0);
    
SendClientMessage(playerid,COLOUR_BLUE,adminDuty[playerid] ? ("You are now on duty!") : ("You are now off duty!"));
    
SetPlayerColor(playerid,adminDuty[playerid] ? COLOUR_BLUE 0xFFFFFFFF);
    
SetPlayerSkin(playerid,adminDuty[playerid] ? 294 0); //if adminDuty[playerid] == 0 then skin=cj
    
new msg[42];
    
format(msgsizeof(msg), adminDuty[playerid] ? ("%s is now on Duty!") : ("%s is now off Duty!"), GetPlayerNameEx(playerid));
    
SendClientMessageToAll(COLOUR_BLUEmsg);
    return 
1;

Reply
#8

Quote:
Originally Posted by KyNe
Посмотреть сообщение
Код:
CMD:aduty(playerid,params[]) //Doesnt need params function
{
	if(PlayerInfo[playerid][Level] >=1 || IsPlayerAdmin(playerid)) //If you use rcon admin delete (PlayerInfo[playerid][pAdmin] >=1 ||
	{
		if (adminDuty[playerid] == 0) //Check if player is on duty
		{
			new Float:x,Float:y,Float:z;
			new Text3D:label = Create3DTextLabel("Admin On Duty!", COLOR_RED,x,y,z, 40.0, 0, 0); //Creates 3d text label at player position
			GetPlayerPos(playerid,x,y,z); //Looks for players position
			SetPlayerHealth(playerid,100000); //makes player godmode
			SetPlayerColor(playerid,COLOR_RED); //set admin colour red
			SetPlayerSkin(playerid,217); //set admin skin to 294
			GivePlayerWeapon(playerid,38,0);
			new string[128]; format(string, sizeof(string), "{FF0000} %s is now on Duty!", PlayerName2(playerid), params[0] ); //here you format string to send to players
			SendClientMessageToAll(COLOR_RED,string); //send string to players
			SendClientMessage(playerid,COLOR_BLUE,"You are now on duty!"); //Tell admin he is now on duty
			Attach3DTextLabelToPlayer(label,playerid,0.0, 0.0, 0.7); //attach 3d text label made before to player
			adminDuty[playerid] = 1; //Set player on duty
		}
		else if (adminDuty[playerid] == 1) //Check if player is on duty
		{
  			new Float:x,Float:y,Float:z;
  			new Text3D:label = Create3DTextLabel("Admin On Duty!", COLOR_RED,x,y,z, 40.0, 0, 0);
  			Delete3DTextLabel(label); //Delete 3d text label saying "Admin On Duty!"
  			SetPlayerHealth(playerid,100); //sets player health back to 100
			new string[128]; format(string, sizeof(string), "{FF0000} %s is now off Duty!", PlayerName2(playerid), params[0] ); //Format string to send to players
			SendClientMessageToAll(COLOR_RED,string); //send players string
			SendClientMessage(playerid,COLOR_BLUE,"You are now off duty!"); //send admin message he is off duty
			adminDuty[playerid] = 0; //sets admin off duty
			ForceClassSelection(playerid);
			SetPlayerHealth(playerid, 0);
		}
 	}
	else
		SendClientMessage(playerid,COLOR_RED,"You are not high level enough!"); //Error message to send to players who arent admins
	return 1;
}
done,but how to make this

when admin duty on,and admin use /kill

they will spawn with Default skin?

how to make they spawn with admin duty skin ( when admin duty on )?
Add into onplayerspawn:
if (adminDuty[playerid] == 1)
{
SetPlayerSkin(playerid, 294);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)