People requesting to join an org
#1

Hey dudes, well I'm creating a roleplay server but I noticed that players could /request to join an org despite the leader not being on.. They couldn't join it but it sends a message to everyone saying "Playername is requesting to join the San Andreas Police Department".

So I thought I would make it so if the leader is not online it would send them a message saying "The leader is not online"... but I can't seem to get it working, heres the code.

pawn Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
      if(!IsPlayerConnected(i))
      {
           if(PlayerInfo[i][Leader] == (( ORG ID )) )
           {
             SendClientMessage(playerid, COLOR, "The leader of this organization is currently not online");
             return 1;
           }
      }
}
Yes I use dini & I feel its something to do with the "IsPlayerConnected", Thanks in advanced.
Reply
#2

Can we see the /request command?
Reply
#3

pawn Код:
COMMAND:request(playerid, params[])
{
    new id;
    new String[MAX_PLAYERS];
    if(sscanf(params,"i", id))return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /request [orgid]");
    GetPlayerName(playerid, pName, sizeof(pName));
    GetPlayerName(playerid, Name, sizeof(Name));
    if(PlayerInfo[playerid][IsInOrg] == 1) return SendClientMessage(playerid, red, "You are already in a organization!");
    if(PlayerInfo[playerid][IsRequesting] == 1) return SendClientMessage(playerid, red," You are already requesting to join an organization!");
    if(PlayerInfo[playerid][Leader] == id || PlayerInfo[playerid][Member] == id) return SCM(playerid, COLOR_GREY, "Your already in this organization");

    if(id == 1)
    {
    format(String,MAX_PLAYERS,"* %s is requesting to join San Andreas Police Department.",Name);
    SendClientMessageToAll(COLOR_ORANGE,String);
    format(File,sizeof(File),AccountLocation, pName);
    {
    dini_IntSet(File, "Request",PlayerInfo[playerid][request] = 1);
    dini_IntSet(File, "Isrequesting",PlayerInfo[playerid][IsRequesting] = 1);
    return 1;
    }
    }
    if(id == 2)
    {
    format(String,MAX_PLAYERS,"* %s is requesting to join National Guard.",Name);
    SendClientMessageToAll(COLOR_ORANGE,String);
    format(File,sizeof(File),AccountLocation, pName);
    {
    dini_IntSet(File, "Request",PlayerInfo[playerid][request] = 2);
    dini_IntSet(File, "Isrequesting",PlayerInfo[playerid][IsRequesting] = 1);
    return 1;
    }
    }
    if(id == 3)
    {
    format(String,MAX_PLAYERS,"* %s is requesting to join San Andreas Fire Department.",Name);
    SendClientMessageToAll(COLOR_ORANGE,String);
    format(File,sizeof(File),AccountLocation, pName);
    {
    dini_IntSet(File, "Request",PlayerInfo[playerid][request] = 3);
    dini_IntSet(File, "Isrequesting",PlayerInfo[playerid][IsRequesting] = 1);
    return 1;
    }
    }
    if(id == 4)
    {
    format(String,MAX_PLAYERS,"* %s is requesting to join The Sons Of Anarchy.",Name);
    SendClientMessageToAll(COLOR_ORANGE,String);
    format(File,sizeof(File),AccountLocation, pName);
    {
    dini_IntSet(File, "Request",PlayerInfo[playerid][request] = 4);
    dini_IntSet(File, "Isrequesting",PlayerInfo[playerid][IsRequesting] = 1);
    return 1;
    }
    }
    if(id == 5)
    {
    format(String,MAX_PLAYERS,"* %s is requesting to join The Grove Street Families.",Name);
    SendClientMessageToAll(COLOR_ORANGE,String);
    format(File,sizeof(File),AccountLocation, pName);
    {
    dini_IntSet(File, "Request",PlayerInfo[playerid][request] = 5);
    dini_IntSet(File, "Isrequesting",PlayerInfo[playerid][IsRequesting] = 1);
    return 1;
    }
    }
    return 1;
}
There you go Sorry about indentation... quiick reply didn't put it in automatically!
Reply
#4

pawn Код:
COMMAND:request(playerid, params[])
{
    new id;
    new String[MAX_PLAYERS];
    if(sscanf(params,"i", id))return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /request [orgid]");
    GetPlayerName(playerid, pName, sizeof(pName));
    GetPlayerName(playerid, Name, sizeof(Name));
    if(PlayerInfo[playerid][IsInOrg] == 1) return SendClientMessage(playerid, red, "You are already in a organization!");
    if(PlayerInfo[playerid][IsRequesting] == 1) return SendClientMessage(playerid, red," You are already requesting to join an organization!");
    if(PlayerInfo[playerid][Leader] == id || PlayerInfo[playerid][Member] == id) return SCM(playerid, COLOR_GREY, "Your already in this organization");
for(new i = 0; i < MAX_PLAYERS; i++)
{      if(!IsPlayerConnected(i))
     {           if(PlayerInfo[i][Leader] == id);
          {             SendClientMessage(playerid, COLOR, "The leader of this organization is currently not online");             return 1;          
}
     }
}

    if(id == 1)
    {
    format(String,MAX_PLAYERS,"* %s is requesting to join San Andreas Police Department.",Name);
    SendClientMessageToAll(COLOR_ORANGE,String);
    format(File,sizeof(File),AccountLocation, pName);
    {
    dini_IntSet(File, "Request",PlayerInfo[playerid][request] = 1);
    dini_IntSet(File, "Isrequesting",PlayerInfo[playerid][IsRequesting] = 1);
    return 1;
    }
    }
    if(id == 2)
    {
    format(String,MAX_PLAYERS,"* %s is requesting to join National Guard.",Name);
    SendClientMessageToAll(COLOR_ORANGE,String);
    format(File,sizeof(File),AccountLocation, pName);
    {
    dini_IntSet(File, "Request",PlayerInfo[playerid][request] = 2);
    dini_IntSet(File, "Isrequesting",PlayerInfo[playerid][IsRequesting] = 1);
    return 1;
    }
    }
    if(id == 3)
    {
    format(String,MAX_PLAYERS,"* %s is requesting to join San Andreas Fire Department.",Name);
    SendClientMessageToAll(COLOR_ORANGE,String);
    format(File,sizeof(File),AccountLocation, pName);
    {
    dini_IntSet(File, "Request",PlayerInfo[playerid][request] = 3);
    dini_IntSet(File, "Isrequesting",PlayerInfo[playerid][IsRequesting] = 1);
    return 1;
    }
    }
    if(id == 4)
    {
    format(String,MAX_PLAYERS,"* %s is requesting to join The Sons Of Anarchy.",Name);
    SendClientMessageToAll(COLOR_ORANGE,String);
    format(File,sizeof(File),AccountLocation, pName);
    {
    dini_IntSet(File, "Request",PlayerInfo[playerid][request] = 4);
    dini_IntSet(File, "Isrequesting",PlayerInfo[playerid][IsRequesting] = 1);
    return 1;
    }
    }
    if(id == 5)
    {
    format(String,MAX_PLAYERS,"* %s is requesting to join The Grove Street Families.",Name);
    SendClientMessageToAll(COLOR_ORANGE,String);
    format(File,sizeof(File),AccountLocation, pName);
    {
    dini_IntSet(File, "Request",PlayerInfo[playerid][request] = 5);
    dini_IntSet(File, "Isrequesting",PlayerInfo[playerid][IsRequesting] = 1);
    return 1;
    }
    }
    return 1;
}


Check the brackets, I just pasted your code in but it should be around about there and try to clean your code up by making correct indentaions as its easyer to read.
Reply
#5

Hey, sorry for a late reply IceCube, but nah that didn't work. It still allowed players to request to join the org despite the owner not being online. Thanks for the help though
Reply
#6

pawn Код:
COMMAND:request(playerid, params[])
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i) && PlayerInfo[i][Leader] >= 1) SendClientMessage(playerid, red, "The leader of this organization is currently online");
        else if(IsPlayerConnected(i) && PlayerInfo[i][Leader] < 1) return SendClientMessage(playerid, red, "The leader of this organization is currently not online");
        //i dont know what level the leade starts from so i just put 1
    }
    new id;
    new String[MAX_PLAYERS];
    if(sscanf(params,"i", id))return SendClientMessage(playerid, COLOR_YELLOW, "Usage: /request [orgid]");
    GetPlayerName(playerid, pName, sizeof(pName));
    GetPlayerName(playerid, Name, sizeof(Name));
    if(PlayerInfo[playerid][IsInOrg] == 1) return SendClientMessage(playerid, red, "You are already in a organization!");
    if(PlayerInfo[playerid][IsRequesting] == 1) return SendClientMessage(playerid, red," You are already requesting to join an organization!");
    if(PlayerInfo[playerid][Leader] == id || PlayerInfo[playerid][Member] == id) return SCM(playerid, COLOR_GREY, "Your already in this organization");

    if(id == 1)
    {
    format(String,MAX_PLAYERS,"* %s is requesting to join San Andreas Police Department.",Name);
    SendClientMessageToAll(COLOR_ORANGE,String);
    format(File,sizeof(File),AccountLocation, pName);
    {
    dini_IntSet(File, "Request",PlayerInfo[playerid][request] = 1);
    dini_IntSet(File, "Isrequesting",PlayerInfo[playerid][IsRequesting] = 1);
    return 1;
    }
    }
    if(id == 2)
    {
    format(String,MAX_PLAYERS,"* %s is requesting to join National Guard.",Name);
    SendClientMessageToAll(COLOR_ORANGE,String);
    format(File,sizeof(File),AccountLocation, pName);
    {
    dini_IntSet(File, "Request",PlayerInfo[playerid][request] = 2);
    dini_IntSet(File, "Isrequesting",PlayerInfo[playerid][IsRequesting] = 1);
    return 1;
    }
    }
    if(id == 3)
    {
    format(String,MAX_PLAYERS,"* %s is requesting to join San Andreas Fire Department.",Name);
    SendClientMessageToAll(COLOR_ORANGE,String);
    format(File,sizeof(File),AccountLocation, pName);
    {
    dini_IntSet(File, "Request",PlayerInfo[playerid][request] = 3);
    dini_IntSet(File, "Isrequesting",PlayerInfo[playerid][IsRequesting] = 1);
    return 1;
    }
    }
    if(id == 4)
    {
    format(String,MAX_PLAYERS,"* %s is requesting to join The Sons Of Anarchy.",Name);
    SendClientMessageToAll(COLOR_ORANGE,String);
    format(File,sizeof(File),AccountLocation, pName);
    {
    dini_IntSet(File, "Request",PlayerInfo[playerid][request] = 4);
    dini_IntSet(File, "Isrequesting",PlayerInfo[playerid][IsRequesting] = 1);
    return 1;
    }
    }
    if(id == 5)
    {
    format(String,MAX_PLAYERS,"* %s is requesting to join The Grove Street Families.",Name);
    SendClientMessageToAll(COLOR_ORANGE,String);
    format(File,sizeof(File),AccountLocation, pName);
    {
    dini_IntSet(File, "Request",PlayerInfo[playerid][request] = 5);
    dini_IntSet(File, "Isrequesting",PlayerInfo[playerid][IsRequesting] = 1);
    return 1;
    }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)