Help ! (+REP)
#1

how to make this as a client message
PHP код:
COMMAND:warn(playeridparams[])
{
    new 
PlayerToWarnReason[128], ReasonMsg[128], Name[24];
    
// Send the command to all admins so they can see it
    
SendAdminText(playerid"/warn"params);
    
// Check if the player has logged in
    
if (APlayerData[playerid][LoggedIn] == true)
    {
        
// Check if the player's admin-level is at least 1
        
if (APlayerData[playerid][PlayerLevel] >= 1)
        {
            if (
sscanf(params"us[128]"PlayerToWarnReason)) SendClientMessage(playerid0xFF0000AA"Usage: \"/warn <PlayerToWarn> <Reason>\"");
            else
                if (
IsPlayerConnected(PlayerToWarn)) // If the player is a valid playerid (he's connected)
                
{
                    
// Increase the number of warnings
                    
APlayerData[PlayerToWarn][Warnings]++;
                    
// Get the name of the player who warned the player
                    
GetPlayerName(playeridNamesizeof(Name));
                    
// Send the warned player a message who warned him and why he's been warned
                    
format(ReasonMsg128"You have been warned by %s %s"AdminLevelName[APlayerData[playerid][PlayerLevel]], Name);
                    
SendClientMessage(PlayerToWarn0xFF0000FFReasonMsg);
                    
format(ReasonMsg128"Reason: %s"Reason);
                    
SendClientMessage(PlayerToWarn0xFF0000FFReasonMsg);
                    
format(ReasonMsg128"~w~Warning %i/%i: ~r~%s~w~"APlayerData[PlayerToWarn][Warnings], AutoKickWarningsReason);
                    
GameTextForPlayer(PlayerToWarnReasonMsg50004);
                    
// Get the name of the warned player
                    
GetPlayerName(PlayerToWarnNamesizeof(Name));
                    
// Let the admin know who has been warned and why
                    
format(ReasonMsg128"You have warned %s (warnings: %i/%i)"NameAPlayerData[PlayerToWarn][Warnings], AutoKickWarnings);
                    
SendClientMessage(playerid0x00FF00FFReasonMsg);
                    
format(ReasonMsg128"Reason: %s"Reason);
                    
SendClientMessage(playerid0xFF0000FFReasonMsg);
                    
// Automatically kick the player if he got 3 warnings (if autokick is enabled)
                    
if ((APlayerData[PlayerToWarn][Warnings] == AutoKickWarnings) && (AutoKickAfterWarn == 1))
                        
Kick(PlayerToWarn);
                }
                else
                    
SendClientMessage(playerid0xFF0000FF"That player isn't online");
        }
        else
            return 
0;
    }
    else
        return 
0
for eg: administrator [adminname] has warned [playername] [reason:blabla]
Reply
#2

PHP код:
format(ReasonMsgsizeof(ReasonMsg), "%s %s has warned %s. Reason: %s"AdminLevelName[APlayerData[playerid][PlayerLevel]], NamePlayerToWarnreason);
SendClientMessageToAll(-1ReasonMsg); 
Replace gametext with that.
Fix the formatting though
Reply
#3

didnt work can u make it in code itself plz ?
Reply
#4

i want like this :
Administrator bugmate has warned code [reason:hahaxd]
Reply
#5

PHP код:
COMMAND:warn(playeridparams[]) 

    new 
PlayerToWarnReason[128], ReasonMsg[128], Name[24], Target[24];
    
// Get the name 
    
GetPlayerName(playeridNamesizeof(Name));
    
GetPlayerName(PlayerToWarnTargetsizeof(Target));     
    
// Send the command to all admins so they can see it 
    
SendAdminText(playerid"/warn"params); 
    
// Check if the player has logged in 
    
if (APlayerData[playerid][LoggedIn] == true
    { 
        
// Check if the player's admin-level is at least 1 
        
if (APlayerData[playerid][PlayerLevel] >= 1
        { 
            if (
sscanf(params"us[128]"PlayerToWarnReason)) SendClientMessage(playerid0xFF0000AA"Usage: \"/warn <PlayerToWarn> <Reason>\""); 
            else 
                if (
IsPlayerConnected(PlayerToWarn)) // If the player is a valid playerid (he's connected) 
                

                    
// Increase the number of warnings 
                    
APlayerData[PlayerToWarn][Warnings]++; 
                    
// Send the warned player a message who warned him and why he's been warned 
                    
format(ReasonMsg128"You have been warned by %s %s"AdminLevelName[APlayerData[playerid][PlayerLevel]], Name); 
                    
SendClientMessage(PlayerToWarn0xFF0000FFReasonMsg); 
                    
                    
format(ReasonMsg128"Reason: %s"Reason); 
                    
SendClientMessage(PlayerToWarn0xFF0000FFReasonMsg); 
                    
                    
format(ReasonMsg128"~w~Warning %i/%i: ~r~%s~w~"APlayerData[PlayerToWarn][Warnings], AutoKickWarningsReason); 
                    
GameTextForPlayer(PlayerToWarnReasonMsg50004); 
                    
// Let the admin know who has been warned and why 
                    
format(ReasonMsg128"You have warned %s (warnings: %i/%i)"TargetAPlayerData[PlayerToWarn][Warnings], AutoKickWarnings); 
                    
SendClientMessage(playerid0x00FF00FFReasonMsg); 
                    
                    
format(ReasonMsg128"Reason: %s"Reason); 
                    
SendClientMessage(playerid0xFF0000FFReasonMsg);
                    
                    
// Send it to all players
                    
format(ReasonMsgsizeof(ReasonMsg), "%s %s has warned %s. [Reason: %s]."AdminLevelName[APlayerData[playerid][PlayerLevel]], NameTargetReason);
                    
SendClientMessageToAll(0xFF0000FFReasonMsg);
                    
// Automatically kick the player if he got 3 warnings (if autokick is enabled) 
                    
if ((APlayerData[PlayerToWarn][Warnings] == AutoKickWarnings) && (AutoKickAfterWarn == 1)) 
                        
Kick(PlayerToWarn); 
                } 
                else 
                    
SendClientMessage(playerid0xFF0000FF"That player isn't online"); 
        } 
        else 
            return 
0
    } 
    else 
        return 
0
Edited it a little.

Should send a message to everybody saying [xx] Cody has warned Cody. Reason: Giggity.
Reply
#6

Код:
new Warns[MAX_PLAYERS];
#define SCM SendClientMessage
Код:
	
CMD:warn(playerid, params[])
{
    new
	id, reason[124], string[124], plrIP[16];

    if(PlayerInfo[playerid][pAdmin] < 1) return SCM(playerid, COLOR_GREY, "You're not authorized to use that command.");
    if(sscanf(params,"us[124]",id,reason)) return SCM(playerid, COLOR_GREY,"[Usage:] /warn [playerid/partofname] [reason].");
    if(!IsPlayerConnected(id)) return SCM(playerid, COLOR_LIGHTRED,"That player is not connected.");
    if(Warns[playerid] >= 5)
	{
		format(string, sizeof(string), "AdmCmd: %s was banned by %s. Reason: 5 warnings.", GetName(playerid), GetName(id));
		SendClientMessageToAll(COLOR_LIGHTRED, string);
		GetPlayerIp(id,plrIP, sizeof(plrIP));
		SendClientMessage(id,COLOR_LIGHTRED,"|___________[BAN INFO]___________|");
		format(string, sizeof(string), "Your name: %s.",GetName(id));
		SendClientMessage(id, COLOR_LIGHTRED, string);
		format(string, sizeof(string), "Your IP: %s.",plrIP);
		SendClientMessage(id, COLOR_LIGHTRED, string);
		format(string, sizeof(string), "Banned by: %s.",GetName(playerid));
		SendClientMessage(id, COLOR_LIGHTRED, string);
		SendClientMessage(id,COLOR_LIGHTRED,"Reason: 5 warnings.");
		SendClientMessage(id,COLOR_LIGHTRED,"|___________[BAN INFO]___________|");
		SetTimerEx("UnsetBan", 500, 0, "i", id);
  	}
	Warns[playerid] += 1;

	format(string, sizeof(string), "AdmCmd: %s was warned by %s, reason: %s", GetName(id), GetName(playerid), reason);
	SendClientMessageToAll(COLOR_LIGHTRED,string);
	return 1;
}
This is the /warn in my script, maybe you can make it work on yours :/
Reply
#7

Quote:
Originally Posted by alexkeward
Посмотреть сообщение
[code]
This is the /warn in my script, maybe you can make it work on yours :/
Why does your warn have ban info?
Reply
#8

It may have been set up to when I /warn someone to many times it bans them, kinda like a /kick would after several kicks

Its setup to 5 warns then a ban
Reply
#9

Here hope you like it, i re-made the cmd
PHP код:
COMMAND:warn(playerid,params[])
{
    new 
Pid[MAX_PLAYER_NAME],reason[128],string[128],Pname[MAX_PLAYER_NAME],Aname[MAX_PLAYER_NAME];
    
SendAdminText(playerid"/warn"params);
    if(
APlayerData[playerid][LoggedIn] != true) return 0//check if the player has logged in
    
if(APlayerData[playerid][PlayerLevel] <= 1) return 0;
    if(
sscanf(params"us[128]",Pid,reason)) return SendClientMessage(playerid0xFF0000AA"Usage: /warn <PlayerToWarn> <Reason>");
    if(!
IsPlayerConnected(Pid)) return SendClientMessage(playerid,0xFF0000FF"That player isn't online");
    
APlayerData[PlayerToWarn][Warnings]++;
    
GetPlayerName(playeridAnamesizeof(Aname));
    
format(string,sizeof(string),"You have been warned by %s %s (warnings %i/%i) . Reason: %s"AdminLevelName[APlayerData[playerid][PlayerLevel]], Aname,APlayerData[Pid][Warnings],AutoKickWarnings,reason);
    
SendClientMessage(Pid0x00FF00FFstring);
    
GetPlayerName(playeridPnamesizeof(Pname));
    
format(string,sizeof(string),"Administrator %s has warned %s(%d).(warnings %i/%i) Reason %s",Aname,Pname,Pid,APlayerData[Pid][Warnings],AutoKickWarnings,reason);
    
SendClientMessageToAll(0xFF0000FFstring);
    if((
APlayerData[Pid][Warnings] == AutoKickWarnings) && (AutoKickAfterWarn == 1))
    {
        
Kick(Pid);
        
format(stringsizeof(string),"%s(%d) has been kicked from the server. Reason: %i/%i warns",Pname,Pid,AutoKickWarnings,AutoKickWarnings);
        
SendClientMessageToAll(0xFF0000FFstring);
    }
    return 
1;

Reply
#10

Thnx for the help ! (+rep)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)