PDA

View Full Version : CMD:hire doesnt work prob.


lulo356
11/01/2015, 09:32 PM
I created an /hire for the fation leaders but it doenst set the players faction when they did /hire And i don't see the problem.

CMD:hire(playerid, params[])
{
new playerb, string[128];
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(!PlayerInfo[playerid][pFacLeader]) return SendClientMessage(playerid, COLOR_GREY, "You are not a faction leader.");
if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /hire [playerid]");
if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
if(PlayerInfo[playerb][pFac]) return SendClientMessage(playerid, COLOR_GREY, "Player is already in a faction.");
if(playerid == playerb) return SendClientMessage(playerid, COLOR_GREY, "You can't invite yourself.");
new idx = Faction[playerb];
PlayerInfo[playerb][pFac] = Faction[playerid];
PlayerInfo[playerb][pFacRank] = 0;
FacInfo[idx][facMembers] ++;
PlayerInfo[playerb][pFacLeader] = 0;
PlayerInfo[playerb][pFacDiv] = 0;
PlayerInfo[playerb][pFacDivLeader] = 0;
Faction[playerid] = 0;
format(string, sizeof(string), " You hired %s in the faction %s.", RPN(playerb), RPFNEx(playerid));
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), " %s has hired you in the %s", RPN(playerid), RPFNEx(playerid));
SendClientMessage(playerb, COLOR_LIGHTBLUE, string);
return 1;
}

lulo356
12/01/2015, 09:08 AM
Someome?

Rabea
12/01/2015, 09:11 AM
CMD:hire(playerid, params[])
{
new playerb, string[128];
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(!PlayerInfo[playerid][pFacLeader]) return SendClientMessage(playerid, COLOR_GREY, "You are not a faction leader.");
if(sscanf(params, "u", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /hire [playerid]");
if(!IsPlayerLoggedIn(playerb)) return SendClientMessage(playerid, COLOR_GREY, "Invalid player id.");
if(PlayerInfo[playerb][pFac]) return SendClientMessage(playerid, COLOR_GREY, "Player is already in a faction.");
if(playerid == playerb) return SendClientMessage(playerid, COLOR_GREY, "You can't invite yourself.");
new idx = Faction[playerb];
FacInfo[idx][facMembers] ++;
PlayerInfo[playerb][pFac] = Faction[playerid];
/* PlayerInfo[playerb][pFacRank] = 0;
FacInfo[idx][facMembers] ++;
PlayerInfo[playerb][pFacLeader] = 0;
PlayerInfo[playerb][pFacDiv] = 0;
PlayerInfo[playerb][pFacDivLeader] = 0;
Faction[playerid] = 0;*/
format(string, sizeof(string), " You hired %s in the faction %s.", RPN(playerb), RPFNEx(playerid));
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), " %s has hired you in the %s", RPN(playerid), RPFNEx(playerid));
SendClientMessage(playerb, COLOR_LIGHTBLUE, string);
return 1;
}

Try this

HazardouS
12/01/2015, 09:14 AM
new idx = Faction[playerb];

Isn't idx 0 all the time? I mean ... playerb is civilian, right?


Faction[playerid] = 0;

Isn't this supposed to keep its value? Playerid is the leader, so he is not leaving his faction.