30.09.2011, 17:58
(
Последний раз редактировалось V_LOPE; 01.10.2011 в 08:32.
)
Problem Solved
if(strcmp(cmd, "/warn", true) == 0)
{
new string[128];
if(IsPlayerConnected(playerid))
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, YOURCOLOR, "USAGE: /warn [playerid/PartOfName] [reason]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if (PlayerInfo[playerid][pAdmin] >= 1)
{
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
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, YOURCOLOR, "USAGE: /warn [playerid/PartOfName] [reason]");
return 1;
}
new year, month,day;
getdate(year, month, day);
format(string, sizeof(string), "You warned %s, reason: %s", giveplayer, (result));
SendClientMessage(playerid, COLOR_YOURCOLOR, string);
format(string, sizeof(string), "You were warned by %s, reason: %s", sendername, (result));
SendClientMessage(giveplayerid, COLOR_YOURCOLOR, string);
format(string, sizeof(string), "AdmCmd: %s was warned by %s, reason: %s", giveplayer, sendername, (result));
SendClientMessageToAll(0xE42217FF, string);
format(string, sizeof(string), "AdmCmd: %s was warned by %s, reason: %s (%d-%d-%d)", giveplayer, sendername, (result),month,day,year);
return 1;
}
}//not connected
}
else
{
format(string, sizeof(string), " %d is not an active player.", giveplayerid);
SendClientMessage(playerid, YOURCOLOR, string);
}
}
return 1;
}
Try this
pawn Код:
|
#define DIALOG_WARN 1
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
if(PlayerInfo[playerid][pAdmin] >=1)
{
ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"WarnText","Please type your warning reason here","Submit","Cancel"); // this will show you a dialog(like the one for register system,where you type in a password,but instead,you'll type here the warning reason)
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid==DIALOG_WARN) // our dialog defined above at the beggining of my reply
{
if(response==0) return SendClientMessage(playerid,COLOR_RED,"Operation aborted"); // you selected cancel
if(response==1)
{
if(!strlen(inputtext)) return SendClientMessage(playerid,COLOR_RED,"You didn't type anything in the box"); // you typed no text,no warning reason
if(strlen(inputtext)) // you typed in a reason
{
new pID=clickedplayerid; // the player id you wanna give the warn
new wName[MAX_PLAYER_NAME]; // you can call this as you wish,but I though of wName( warned name)
GetPlayerName(pID,wName,sizeof(wName)); // gets the pID name
new string[120]; // the string we gonna use for the warning statement
format(string,sizeof(string),"%s(%d) has been warned by an admin.Reason:%s",wName,pID,inputtext); // the statement itself sending the warned name,his ID,and the reason
SendClientMessageToAll(COLOR_RED,string); // the message is sent to every player
}
return true;
}
pawn Код:
pawn Код:
clickedplayerid = The player you clicked. source(not needed in this case) = of couurse the scoreboard; pawn Код:
pawn Код:
|
new Warnings[MAX_PLAYERS]; // TOP
Warnings[playerid] = 0; // OnPlayerConnect
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid==DIALOG_WARN) //
{
if(response==0) return SendClientMessage(playerid,COLOR_RED,"Operation aborted");
if(response==1)
{
if(!strlen(inputtext)) return SendClientMessage(playerid,COLOR_RED,"You didn't type anything in the box");
new pID = clickedplayerid;
new wName[MAX_PLAYER_NAME];
GetPlayerName(pID,wName,sizeof(wName));
new string[120];
format(string,sizeof(string),"%s(%d) has been warned by an admin.Reason:%s",wName,pID,inputtext);
SendClientMessageToAll(COLOR_RED,string);
Warnings[pID] += 1;
if(Warnings[pID] >= 3)
{
SendClientMessage(pID, -1, "3/3 Warnings, kicked"):
Kick(pID);
}
}
}
return true;
}
Cjgogo edit:
pawn Код:
|