/invite and /acceptinvite not working :/
#2

Well, you need to learn about elseif. Currently if the invitedFor isn't equal 7, you'll get error

BTW: Your code can be a little shorter (which also includes the fix)

pawn Код:
CMD:invite(playerid, params[])
{
    new player;
    if(sscanf(params, "u", player)) return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /invite [playerid / name]");
    if(player != INVALID_PLAYER_ID)
    {
        if(PlayerInfo[playerid][pLeader] == 1 && 1 <= PlayerInfo[playerid][pTeam] <= 7)
        {
            new string[128];
            new stringtarget[128];
            new pName[MAX_PLAYER_NAME], aName[MAX_PLAYER_NAME];
            GetPlayerName(playerid, aName, MAX_PLAYER_NAME);
            GetPlayerName(player, pName, MAX_PLAYER_NAME);
            invitedFor[player] = PlayerInfo[playerid][pTeam];
            format(string, sizeof(string), "You have invited %s to join %s", pName, FactionStatus(playerid));
            format(stringtarget, sizeof(stringtarget), "You have been invited to join %s. Type "COL_RED"/acceptinvite"COL_WHITE" to join!", FactionStatus(playerid));
            SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
            SendClientMessage(playerid, COLOR_LIGHTBLUE, stringtarget);
        }
    }
    else
    {
        SendClientMessage(playerid, -1, "* The player is not online.");
    }
    return 1;
}

CMD:acceptinvite(playerid, params[])
{
    new player;
    if(player != INVALID_PLAYER_ID)
    {
        new string[128];
        new aName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, aName, MAX_PLAYER_NAME);
        if(1 <= invitedFor[playerid] <= 7)
        {
            PlayerInfo[playerid][pTeam] = invitedFor[playerid];
            PlayerInfo[playerid][pLeader] = 0;
            PlayerInfo[playerid][pRank] = 1;
            format(string, sizeof(string), "You have accepted the invitation and you are now part of %s", FactionStatus(playerid));
            invitedFor[playerid] = 0;
        } else
        {
            SendClientMessage(playerid, -1, "You dont have a pending invitation!");
        }
    }
    else
    {
        SendClientMessage(playerid, -1, "* The player is not online.");
    }
    return 1;
}
Reply


Messages In This Thread
/invite and /acceptinvite not working :/ - by arjanforgames - 15.07.2013, 10:02
Re: /invite and /acceptinvite not working :/ - by Misiur - 15.07.2013, 10:06
Re: /invite and /acceptinvite not working :/ - by arjanforgames - 15.07.2013, 11:12
Re: /invite and /acceptinvite not working :/ - by Misiur - 15.07.2013, 12:48
Re: /invite and /acceptinvite not working :/ - by arjanforgames - 15.07.2013, 12:50
Re: /invite and /acceptinvite not working :/ - by Misiur - 15.07.2013, 13:14
Re: /invite and /acceptinvite not working :/ - by arjanforgames - 15.07.2013, 13:20

Forum Jump:


Users browsing this thread: 2 Guest(s)