Creating a static faction system, help with command.
#1

Hey, I need help with my /invite command.. This is what I have so far..

PHP Code:
CMD:invite(playerid,params[])
{
    new
        
targetid;
    if(
PlayerInfo[playerid][Group] == 255) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]: You're not in a group ");
    if(
sscanf(params,"u",targetid)) return SendClientMessage(playerid,COLOR_SYNTAX,"[SYNTAX]: /invite [targetid] ");
    if(
targetid==INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]: Player is not connected. ");
    else
    {
        if(
PlayerInfo[playerid
I'm stuck at getting the players faction id who sends the invite, so the person gets invited into their group.
Reply
#2

What enum are you using for the factions or for the PlayerInfo[MAX_PLAYERS]?
Reply
#3

Player who sends the invite is - playerid ,to get player who RECEIVES the invite - you defined him as targetid, your code is good, tho I do not remember what "u" stands for, an integer or else. You should have some faction code defined above, look for it.

edit: ah silly me, you have it. To get player faction id use: PlayerInfo[playerid][Group]. If you want to check if he is in some kind of group, use:

if(PlayerInfo[playerid][Group] < 255) (Not sure about your group numbers)
Reply
#4

Something like this?
pawn Code:
CMD:invite(playerid,params[])
{
    if(PlayerInfo[playerid][pGroup] == 1)
    {
        new targetid;
        if(PlayerInfo[playerid][Group] == 255) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]: You're not in a group ");
        if(sscanf(params,"u",targetid)) return SendClientMessage(playerid,COLOR_SYNTAX,"[SYNTAX]: /invite [targetid] ");
        if(targetid==INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]: Player is not connected. ");
        else
        {
            PlayerInfo[playerid][pGroup] =1;
            SendClientMessage(targetid, COLOR_GREY, "You've have been invited to our Group.");
        }
    }
    else if(PlayerInfo[playerid][pGroup] == 2)
    {
        new targetid;
        if(PlayerInfo[playerid][Group] == 255) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]: You're not in a group ");
        if(sscanf(params,"u",targetid)) return SendClientMessage(playerid,COLOR_SYNTAX,"[SYNTAX]: /invite [targetid] ");
        if(targetid==INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]: Player is not connected. ");
        else
        {
            PlayerInfo[playerid][pGroup] =2;
            SendClientMessage(targetid, COLOR_GREY, "You've have been invited to our Group.");
        }
    }
Reply
#5

My enum is PlayerInfo[MAX_PLAYERS][pInfo] and wild cookie.. I know the player who sends the invite is the playerid, and who recieves is targetid.. Im not a total noob, u is a sscanf param and stands for part of name/id

Safot , There is a more efficient way to do It I think..
Reply
#6

Quote:
Originally Posted by wildcookie007
View Post
Player who sends the invite is - playerid ,to get player who RECEIVES the invite - you defined him as targetid, your code is good, tho I do not remember what "u" stands for, an integer or else. You should have some faction code defined above, look for it.

edit: ah silly me, you have it. To get player faction id use: PlayerInfo[playerid][Group]. If you want to check if he is in some kind of group, use:

if(PlayerInfo[playerid][Group] < 255) (Not sure about your group numbers)
Quote:
Originally Posted by Azzeto
View Post
I'm stuck at getting the players faction id who sends the invite, so the person gets invited into their group.
Not the player.
Reply
#7

Quote:
Originally Posted by Sasoft
View Post
Something like this?
pawn Code:
CMD:invite(playerid,params[])
{
    if(PlayerInfo[playerid][pGroup] == 1)
    {
        new targetid;
        if(PlayerInfo[playerid][Group] == 255) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]: You're not in a group ");
        if(sscanf(params,"u",targetid)) return SendClientMessage(playerid,COLOR_SYNTAX,"[SYNTAX]: /invite [targetid] ");
        if(targetid==INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]: Player is not connected. ");
        else
        {
            PlayerInfo[playerid][pGroup] =1;
            SendClientMessage(playerid, COLOR_GREY, "You've have been invited to our Group.");
        }
    }
    else if(PlayerInfo[playerid][pGroup] == 2)
    {
        new targetid;
        if(PlayerInfo[playerid][Group] == 255) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]: You're not in a group ");
        if(sscanf(params,"u",targetid)) return SendClientMessage(playerid,COLOR_SYNTAX,"[SYNTAX]: /invite [targetid] ");
        if(targetid==INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_ERROR,"[ERROR]: Player is not connected. ");
        else
        {
            PlayerInfo[playerid][pGroup] =2;
            SendClientMessage(playerid, COLOR_GREY, "You've have been invited to our Group.");
        }
    }
I'd say thats a waste of time and code if he has like hundreds of groups. Basically check if he is in some kind of group and give the targetid an invite, example:

InvitedToGroup[targetid] = PlayerInfo[playerid][pGroup];

after he writes /accept or whatever, just set his PlayerInfo[playerid][pGroup]=InvitedToGroup[playerid]; // playerid because in /accept cmd he will be the player.

edit: sry for misunderstanding in my first post ^^
Reply
#8

Thanks but I figured it out, it was pretty simple.

Way to Do IT:

PHP Code:
    else
    {
        
group PlayerInfo[playerid][Group];
        
PlayerInfo[targetid][Group] = group;
        
format(string,sizeof(string),"[HIRED]: You've been hired to group %d.",group);
        
SendClientMessage(targetid,COLOR_YELLOW,string);
    } 
Figured it out :P
Reply
#9

That's what I wrote, but you are using an additional variable to store targetid invited groupwhich is not necessary since it stores in my way without using additional varibale.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)