SA-MP Forums Archive
/accept invite? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: /accept invite? (/showthread.php?tid=461120)



/accept invite? - Pawnie - 31.08.2013

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;
}



Re : /accept invite? - 1Geek - 31.08.2013

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


Re: /accept invite? - Dragonsaurus - 31.08.2013

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;
}



Re : Re: /accept invite? - 1Geek - 31.08.2013

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


Re: /accept invite? - Pawnie - 31.08.2013

Thanks a lot!!!!