31.08.2013, 16:08
pawn Код:
new RequesterID[MAX_PLAYERS] = -1; // On top of your script
CMD:invite(playerid, params[])
{
if(PlayerInfo[playerid][pLeader] >= 1)
{
new otherplayerid;
if(sscanf(params, "u", otherplayerid)) SendClientMessage(playerid, COLOR_RED, "/invite [playerid/name]");
else if(otherplayerid == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_RED, "Player not connected");
else
{
new string[160];
format(string, sizeof(string), "{FF0000}%s {FFFFFF}has invited you to join their team!\n\nType {00FF00}Accept{FFFFFF} to join, or {FF0000}Deny{FFFFFF} to cancel!", GetPlayerNameEx(otherplayerid));
ShowPlayerDialog(otheplayerid, 9374, DIALOG_STYLE_MSGBOX, "Join Team Request", string, "Accept", "Deny");
RequesterID[otherplayerid] = playerid;
}
}
else SendClientMessage(playerid, COLOR_RED, "You are not a team leader!");
return 1;
}
// Under OnDialogResponse:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 9374)
{
new string[96];
if(response)
{
PlayerInfo[playerid][pTeam] = PlayerInfo[RequesterID[playerid]][pTeam];
format(string, sizeof(string), "%s has accepted %s's invitation to join their team!", playerid, RequesterID[playerid]);
SendClientMessageToAll(0x00FF00FF, string);
}
else
{
format(string, sizeof(string), "%s has denied %s's invitation to join their team!", playerid, RequesterID[playerid]);
SendClientMessageToAll(0xFF0000FF, string);
}
}
return 0;
}