My /invite cmd..
#1

PHP код:
CMD:invite(playerid,params[])
{
    new 
string[128],id,sendername[MAX_PLAYER_NAME];
    if(
PlayerInfo[playerid][pGroup] <= 0) return SendClientMessage(playerid,COLOR_GRAY,"You're not part of a group!");
    else if(
sscanf(params,"u",id)) return SendClientMessage(playerid,COLOR_GRAY,"Syntax: /invite [id]");
    else if(
id==INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_GRAY,"Error: Player is not connected!");
    else
    {
        
PlayerInfo[playerid][pGroup] = id;
        
PlayerInfo[playerid][pRank] = 1;
        
GetPlayerName(playeridsendernamesizeof(sendername));
        if(
PlayerInfo[playerid][pGroup] == 1) return PlayerInfo[id][pGroup] == 1;
        else if(
PlayerInfo[playerid][pGroup] == 2) return PlayerInfo[id][pGroup] == 2;
        else if(
PlayerInfo[playerid][pGroup] == 3) return PlayerInfo[id][pGroup] == 3;
        else if(
PlayerInfo[playerid][pGroup] == 4) return PlayerInfo[id][pGroup] == 4;
        else if(
PlayerInfo[playerid][pGroup] == 5) return PlayerInfo[id][pGroup] == 5;
        else if(
PlayerInfo[playerid][pGroup] == 6) return PlayerInfo[id][pGroup] == 6;
        else if(
PlayerInfo[playerid][pGroup] == 7) return PlayerInfo[id][pGroup] == 7;
        else if(
PlayerInfo[playerid][pGroup] == 8) return PlayerInfo[id][pGroup] == 8;
        else if(
PlayerInfo[playerid][pGroup] == 9) return PlayerInfo[id][pGroup] == 9;
        else if(
PlayerInfo[playerid][pGroup] == 10) return PlayerInfo[id][pGroup] == 10;
        
format(string,sizeof(string),"[INVITE] %s has invited you to group %d",sendername,id);
        
SendClientMessage(id,COLOR_YELLOW,string);
    }
    return 
1;

When I invite some one it says to the person "[INVITE] You have been invited to group 0" Even if I set my group to 1.. And should this save it to there player file? I need to know how to fix it so they get invited to the group that they got invited to.
Reply
#2

pawn Код:
format(string,sizeof(string),"[INVITE] %s has invited you to group %d",sendername,id);
id(the target ID) is the param of the command. And of course, if the id you are trying to "invite" is 0, it's normal for it to show 0. If you want to set a group id, add another param to the command!
Reply
#3

Lets see, if I understand your command correctly, it does this: You invite a player (where in your command id = the playerid of the player you want to invite?) to the group you are currently in?

pawn Код:
CMD:invite(playerid,params[])
{
    new string[128],id,sendername[MAX_PLAYER_NAME];
    if(PlayerInfo[playerid][pGroup] <= 0) return SendClientMessage(playerid,COLOR_GRAY,"You're not part of a group!");
    else if(sscanf(params,"u",id)) return SendClientMessage(playerid,COLOR_GRAY,"Syntax: /invite [id]");
    else if(id==INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_GRAY,"Error: Player is not connected!");
    else
    {
        PlayerInfo[playerid][pRank] = 1;
        GetPlayerName(playerid, sendername, sizeof(sendername));
        /*if(PlayerInfo[playerid][pGroup] == 1) return PlayerInfo[id][pGroup] == 1;
        else if(PlayerInfo[playerid][pGroup] == 2) return PlayerInfo[id][pGroup] == 2;
        else if(PlayerInfo[playerid][pGroup] == 3) return PlayerInfo[id][pGroup] == 3;
        else if(PlayerInfo[playerid][pGroup] == 4) return PlayerInfo[id][pGroup] == 4;
        else if(PlayerInfo[playerid][pGroup] == 5) return PlayerInfo[id][pGroup] == 5;
        else if(PlayerInfo[playerid][pGroup] == 6) return PlayerInfo[id][pGroup] == 6;
        else if(PlayerInfo[playerid][pGroup] == 7) return PlayerInfo[id][pGroup] == 7;
        else if(PlayerInfo[playerid][pGroup] == 8) return PlayerInfo[id][pGroup] == 8;
        else if(PlayerInfo[playerid][pGroup] == 9) return PlayerInfo[id][pGroup] == 9;
        else if(PlayerInfo[playerid][pGroup] == 10) return PlayerInfo[id][pGroup] == 10;
                */

          PlayerInfo[id][pGroup] = PlayerInfo[playerid][pGroup];
        format(string,sizeof(string),"[INVITE] %s has invited you to group %d",sendername,id);
        SendClientMessage(id,COLOR_YELLOW,string);
    }
    return 1;
}
What I did:
- Removed the line "PlayerInfo[playerid][pGroup] = id;" because you were setting the groupid of the player that was inviting to the id of the player he was inviting
- Replaced the commented lines with "PlayerInfo[id][pGroup] = PlayerInfo[playerid][pGroup];"

It was a simple fix, hope it is what you wanted
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)