15.09.2012, 15:43
Hey, I was wondering if anyone could teach me how to create a faction? let's say LSPD.
enum pInfo { pLeader, pRank, pMember }; new PlayerInfo[MAX_PLAYERS][pInfo]; Making somebody a leader. (Took from my script) CMD:makeleader(playerid, params[]) { if (PlayerInfo[playerid][pAdmin] >= 5) { new string[128], giveplayerid, faction; if(sscanf(params, "ud", giveplayerid, faction)) { SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /makeleader [playerid] [factionid]"); SendClientMessageEx(playerid, COLOR_LIGHTGREEN, "|1 LSPD |2 FBI |3 FDSA |4 SAAS"); return 1; } if(faction > 13 || faction < 0) { SendClientMessageEx(playerid, COLOR_YELLOW, "Don't go below number 0 or above number 4!"); return 1; } if(IsPlayerConnected(giveplayerid)) { new ftext[30]; PlayerInfo[giveplayerid][pLeader] = faction; PlayerInfo[giveplayerid][pRank] = 6; PlayerInfo[giveplayerid][pMember] = faction; if(PlayerInfo[giveplayerid][pLeader] == 1) { ftext = "LSPD"; } else if(PlayerInfo[giveplayerid][pLeader] == 2) { ftext = "FBI"; } else if(PlayerInfo[giveplayerid][pLeader] == 3) { ftext = "FSDA"; } else if(PlayerInfo[giveplayerid][pLeader] == 4) { ftext = "SAAS"; } else { return 1; } format(string, sizeof(string), "You have been made the leader of the %s by Administrator %s.",ftext, GetPlayerNameEx(playerid)); SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string); format(string, sizeof(string), "You have made %s the leader of the %s.", GetPlayerNameEx(giveplayerid),ftext); SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string); } } else { SendClientMessage(playerid, COLOR_GRAD1, "You are not authorized to use that command!"); } return 1; } |
chill guys, I've been scripting 2000 lines in my current script, and I am just using this script to train myself. It would be great if someone could explain it properly how to make a faction. Not like TDM faction but RP. That makeleader is nice, seems very common to me using sscanf2 and zcmd, so that's a good start actually.. But, could anyone try to make it for me and explain the lines, so I could like make it stuck to my head?
|
enum pInfo { pLeader, pRank, pMember };
CMD:giverank(playerid, params[]) { new pID, value; new rank = PlayerInfo[playerid][pLeader]; if(rank < 6) return SCM(playerid, COLOR_WHITE, "You are not authorised to use that command."); else if (sscanf(params, "ui", pID, value)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /giverank [playerid/partofname] [rank 0-6]"); else if (value < 0 || value > 6) return SendClientMessage(playerid, COLOR_WHITE, "Unknown rank! [0 - 6]"); else if(pID == INVALID_PLAYER_ID) return SCM(playerid, COLOR_WHITE,"Invalid player ID."); else { new pName[MAX_PLAYER_NAME], tName[MAX_PLAYER_NAME], string[128]; GetPlayerName(playerid, pName, MAX_PLAYER_NAME); GetPlayerName(pID, tName, MAX_PLAYER_NAME); format(string, sizeof(string), "You have promoted %s to rank %i!", tName, value); SCM(playerid, COLOR_LIGHTBLUE, string); format(string, sizeof(string), "You have been promoted to rank %i!", value, pName); SCM(pID, COLOR_LIGHTBLUE, string); PlayerInfo[pID][pRank] = value; } return 1; }