jomarisk8er Posted May 25, 2012 Share Posted May 25, 2012 function onChat(player,_,...) local msg = table.concat({...}, " ") local nick = getPlayerName(player) local r,g,b = getPlayerNametagColor(player) local vehicle = getPedOccupiedVehicle(player) local accName = getAccountName(getPlayerAccount(player)) local gang = exports.gang_system:getAccountGang(accName) local sendto = exports.gang_system:getGangMembers(gang) for seats,v in pairs(sendto) do if (isElement(v) and getElementType(v) == "player") then outputChatBox("#FF00FF(GC) "..(nick)..": #FFFFFF"..(msg).." ", v, r, g, b, true) end end end addCommandHandler("gc", onChat) this is my Code, its working when im typing /gc hello there. like that, cause i want to send the msg to all in my gang members, i dont know much in pairs,for,do thing pls help, IG : Tasyo Link to comment
Alpha Posted May 25, 2012 Share Posted May 25, 2012 I don't understand, what happens? Any errors in /debugscript? Link to comment
Flaker Posted May 25, 2012 Share Posted May 25, 2012 If u want just send msg to all members of ur gang, try this: function onChat(source,_,...) local account = getPlayerAccount ( source ) local accountName = getAccountName ( account ) local gangName = exports.gang_system:getAccountGang ( accountName ) local msg = table.concat({...}, " ") local nick = getPlayerName(source) for _, member in ipairs ( exports.gang_system:getGangMembers ( gangName ) ) do outputChatBox("#FF00FF(GC) "..nick..": #FFFFFF"..msg,member,255,100,0,true) end end addCommandHandler("gc",onChat) Link to comment
Alpha Posted May 25, 2012 Share Posted May 25, 2012 His code already contained all that, he should tell us first what happens exactly. Link to comment
jomarisk8er Posted May 25, 2012 Author Share Posted May 25, 2012 Flaker, its working, but why its spamming like 5 times. Link to comment
jomarisk8er Posted May 25, 2012 Author Share Posted May 25, 2012 and there a problem again, it sending from all players T_T Link to comment
jomarisk8er Posted May 25, 2012 Author Share Posted May 25, 2012 its not working T_T , it is exported from Castillo's gang system ... Link to comment
Alpha Posted May 25, 2012 Share Posted May 25, 2012 The resource is compiled, so I can't see how is the value returned, guess you will have to wait for Castillo. Link to comment
jomarisk8er Posted May 25, 2012 Author Share Posted May 25, 2012 in description, you can see the exports. you can look if im right or wrong from defining it Link to comment
Alpha Posted May 25, 2012 Share Posted May 25, 2012 It should return a table with the players, but I don't see a problem with your code. Link to comment
Flaker Posted May 25, 2012 Share Posted May 25, 2012 Try this: function onChat(source,_,...) local account = getPlayerAccount ( source ) local accountName = getAccountName ( account ) local gangName = exports.gang_system:getAccountGang ( accountName ) local msg = table.concat({...}, " ") local nick = getPlayerName(source) if (gangName) and not(gangName == "None") then --Check source's gang (as example) for _, member in ipairs ( exports.gang_system:getGangMembers ( gangName ) ) do if (isElement(member) and getElementType(member) == "player") then outputChatBox("#FF00FF(GC) "..nick..": #FFFFFF"..msg,member,255,100,0,true) end end end end addCommandHandler("gc",onChat) anyways, we should know what func "getGangMembers"return etc... Also, what func "getAccountGang" return, if player isn't at gang. Link to comment
jomarisk8er Posted May 25, 2012 Author Share Posted May 25, 2012 @flaker, still not working T_T , it doesnt send any message , even to me Link to comment
Flaker Posted May 25, 2012 Share Posted May 25, 2012 That mean, that problem is in "if (gangName) and not(gangName == "None") then" Ask Castillo then... Link to comment
jomarisk8er Posted May 25, 2012 Author Share Posted May 25, 2012 oh ok thanks any Flaker .. i will wait for castillo Link to comment
Kenix Posted May 25, 2012 Share Posted May 25, 2012 (edited) It's a stupid idea compiling each resource for community. All should see the code. I know some situations where guys compile resources with commands like /giveadmin, /shutdown and upload them to the community. In your place I would write your owns. Edited May 25, 2012 by Guest Link to comment
Flaker Posted May 25, 2012 Share Posted May 25, 2012 oh ok thanks any Flaker .. i will wait for castillo No Problem) Link to comment
jomarisk8er Posted May 25, 2012 Author Share Posted May 25, 2012 hey kenix, can you help me for that script .. Link to comment
Flaker Posted May 25, 2012 Share Posted May 25, 2012 Try this: function onChat(source,_,...) local gang_members = {} local account = getPlayerAccount ( source ) local accountName = getAccountName ( account ) local gangName = exports.gang_system:getAccountGang ( accountName ) local msg = table.concat({...}, " ") local nick = getPlayerName(source) if (gangName) and not(gangName == 'None') then local gang_members = exports.gang_system:getGangMembers ( gangName ) for id, cur_player in ipairs (gang_members) do outputChatBox("#FF00FF(GC) "..nick..": #FFFFFF"..msg,cur_player,255,100,0,true) end end end addCommandHandler("gc",onChat) btw, I just found it: [-] Exported functions: addGang - Arguments: gangName, gangLeader. Returns: true or false. removeGang - Arguments: gangName. Returns: true or false. doesGangExists - Arguments: gangName. Returns: true or false. getGangList - Arguments: None. Returns: A table with gang list. getGangMembers - Arguments: gangName. Returns: A table with gang members. addGangMember - Arguments: gangName, accountName, addedBy. Returns: true or false (if false, it'll return a second argument with the error.). removeGangMember - Arguments: gangName, accountName, kickerName (if used it'll output who kicked the member, else it'll output that you left). isGangMember - Arguments: gangName, accountName. Returns: true or false. getAccountGang - Arguments: accountName. Returns: The gang name, 'None' otherwise. getGangLeader - Arguments: gangName. Returns: The gang leader. getGangSubLeaders - Arguments: gangName. Returns: A JSON string with gang sub leaders. isPlayerGangInvited - Arguments: thePlayer. Returns: 3 arguments: invited, gangName, inviter. getPlayersByGang - Arguments: gangName. Returns: A table with gang players. isGangSubLeader - Arguments: gangName, accountName. Returns: true or false. Link to comment
Castillo Posted May 25, 2012 Share Posted May 25, 2012 It's a stupid idea compiling each resource for community. All should see the code. I know some situations where guys compile resources with commands like /giveadmin, /shutdown and upload them to the community.In your place I would write your owns. I would never do that, know why? because I don't need to, also, my resources doesn't need any ACL privileges, so it would be impossible to do it . @Back on topic: The function getGangMembers returns a table with the account names of the members. You should've using the "gang" element data to check who's in that gang. Your script should look like this: function onChat ( thePlayer, _, ... ) local account = getPlayerAccount ( thePlayer ) local accountName = getAccountName ( account ) local gangName = exports.gang_system:getAccountGang ( accountName ) if ( gangName and gangName ~= "None" ) then local msg = table.concat ( { ... }, " " ) local nick = getPlayerName ( thePlayer ) for index, player in ipairs ( getElementsByType ( "player" ) ) do if ( getElementData ( player, "gang" ) == gangName ) then outputChatBox ( "#FF00FF(GC) ".. nick ..": #FFFFFF".. msg, player, 255, 100, 0, true ) end end end end addCommandHandler ( "gc", onChat ) Link to comment
jomarisk8er Posted May 26, 2012 Author Share Posted May 26, 2012 thanks castillo it works. Edit: castillo, can i have request? can you put gang color so i can apply it in turfing system? .. pls Link to comment
Castillo Posted May 26, 2012 Share Posted May 26, 2012 You're welcome. About that request: I may think about it. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now