/accept invite?
#1

So I made /invite command, but how do I let the player choose will he join it or not? /accept or /deny it?

pawn Код:
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[72];
            format(string, sizeof(string), "<!>%s has invited you to join their team!", GetPlayerNameEx(otherplayerid));
            SendClientMessage(otherplayerid, COLOR_WHITE,string);
            PlayerInfo[otherplayerid][pTeam] = PlayerInfo[playerid][pTeam];
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_RED, "You are not a team leader!");
    }
    return 1;
}
Reply
#2

pawn Код:
COMMAND:acceptgang(playerid, params[])
{
    new str[128];
        if(PlayerStat[playerid][BeingInvitedToGang] == 0) return SendClientMessage(playerid, GREY, "Nobody invited you to join a gang.");
        PlayerStat[playerid][GangID] = PlayerStat[playerid][BeingInvitedToGang];
    PlayerStat[playerid][GangRank] = 1;
        PlayerStat[playerid][BeingInvitedToGang] = 0;
        format(str, sizeof(str), "%s has accepted to join %s, Welcome!", GetName(playerid), GangStat[PlayerStat[playerid][GangID]][GangName]);
    SendGangMessage(playerid, GangStat[PlayerStat[playerid][GangID]][Color], str);
    GangStat[PlayerStat[playerid][GangID]][Members] += 1;
    format(GangStat[PlayerStat[playerid][GangID]][GangFile], 60, "Gangs/Gang %d.ini", PlayerStat[playerid][GangID]);
    SaveGang(GangStat[PlayerStat[playerid][GangID]][GangFile]);
    SavePlayerGangInfo(playerid);
    return 1;
}
Try this. You need ZCMD / SSCANF2
Just remplace the "Gang" words by something else and enjoy
Reply
#3

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;
}
Reply
#4

Quote:
Originally Posted by Dragonsaurus
Посмотреть сообщение
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;
}
Very good one
Reply
#5

Thanks a lot!!!!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)