Spajk Posted May 16, 2011 Share Posted May 16, 2011 I need someone to test my script function create( playerSource, commandName, name ) local acc = getPlayerAccount ( playerSource ) local gang = getAccountData( acc,"gang") if(gang) then outputChatBox ( "You already have a gang, use /gangleave to leave it!", playerSource ) else if getAccount( "gang-" ..name.."") then outputChatBox ( "Account name alreaady exist.", playerSource ) ` else local money = getPlayerMoney(playerSource) if( money < 1000000 ) then outputChatBox ( "You don't have enough money!", playerSource ) else local accname = getAccountName( acc ) local gangacc = addAccount( "gang-" ..name.."", "nisamkodkucejermiseoce" ) setAccountData ( gangacc,"leader",accname ) setAccountData ( gangacc,"name",name ) setAccountData ( acc,"gang","gang-" ..name.."" ) local team = createTeam(name) setPlayerTeam" class="kw6">setPlayerTeam" class="kw6">setPlayerTeam( playerSource, team ) takePlayerMoney( playerSource, 1000000 ) setAccountData ( gangacc,"members",1 ) outputChatBox ( "Gang "..name.." sucesfully created!", playerSource ) end end end end function invite( playerSource, commandName, name ) local acc = getPlayerAccount ( playerSource ) local gang = getAccountData( acc,"gang") if( gang ) then local gangacc = getAccount(gang) local gangname = getAccountData( gangacc,"name") local gangleader = getAccountData( gangacc,"leader") if(leader==acc) then new player = getPlayerFromName( name ) if(player) then outputChatBox ( "Tou have been invited to join "..gangname.." .use /gangaccept to accept this gang!", player ) local playeracc = getPlayerAccount ( player ) setAccountData(playeracc,"invite","gang-"..name.."") else outputChatBox ( "Player "..name.." doesn't exist", playerSource ) end else outputChatBox ( "You aren't leader of this gang!", playerSource ) end end end function accept( playerSource ) local acc = getPlayerAccount ( playerSource ) local gang = getAccountData( acc,"gang") if(gang) then outputChatBox ( "You already have a gang, use /gangleave to leave it!", playerSource ) else gang = getAccountData( acc,"invite") if(invite) then local gangacc = getAccount(gang) local gangname = getAccountData( gangacc,"name") local members = getAccountData ( gangacc,"members") setAccountData ( acc,"gang",gang ) setPlayerTeam" class="kw6">setPlayerTeam(playerSource,name) members = members + 1 setAccountData (gangacc,"members",members) outputChatBox ( "You joind in gang "..gangname.." !", playerSource ) else outputChatBox ( "You haven't been invited in any gang!", playerSource ) end end end function leave( playerSource ) local acc = getPlayerAccount ( playerSource ) local gang = getAccountData( acc,"gang") local gangacc = getAccount(gang) local gangname = getAccountData( gangacc,"name") if(gang) then outputChatBox ( "You leaved gang "..gangname.."!", playerSource ) local members = getAccountData ( gangacc,"members") members = members - 1 setAccountData (gangacc,"members",members) setAccountData ( acc,"gang","") else outputChatBox ( "You don't have a gang!", playerSource ) end end function kick( playerSource, commandName, name ) local acc = getPlayerAccount ( playerSource ) local gang = getAccountData( acc,"gang") if ( gang ) then local gangacc = getAccount(gang) local gangname = getAccountData( gangacc,"name") local gangleader = getAccountData( gangacc,"leader") if(leader==acc) then new player = getPlayerFromName( name ) if(player) then outputChatBox ( "You have been kicked from gang "..gangname.."!", player ) outputChatBox ( "You kicked "..name.." from gang!", player ) local members = getAccountData ( gangacc,"members") members = members - 1 setAccountData (gangacc,"members",members) setAccountData ( acc,"gang","") else outputChatBox ( "Player "..name.." doesn't exist", playerSource ) end else outputChatBox ( "You aren't leader of this gang!", playerSource ) end end end function onPlayerLogin ( ) local acc = getPlayerAccount ( source ) local gang = getAccountData( acc,"gang") if ( gang ) then local gangacc = getAccount(gang) local gangname = getAccountData( gangacc,"name") local team = getTeamFromName ( gangname ) setPlayerTeam" class="kw6">setPlayerTeam" class="kw6">setPlayerTeam( source, team ) end end addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) addCommandHandler ( "gangcreate", create ) addCommandHandler ( "ganginvite", invite ) addCommandHandler ( "gangaccept", accept ) addCommandHandler ( "gangleave", leave ) addCommandHandler ( "gangkick", kick ) Link to comment
CowTurbo Posted May 16, 2011 Share Posted May 16, 2011 be ready, im seting server up lolz Link to comment
CowTurbo Posted May 16, 2011 Share Posted May 16, 2011 function create( playerSource, commandName, name ) local acc = getPlayerAccount ( playerSource ) local gang = getAccountData( acc,"gang") if(gang) then outputChatBox ( "You already have a gang, use /gangleave to leave it!", playerSource ) else if getAccount( "gang-" ..name.."") then outputChatBox ( "Account name alreaady exist.", playerSource ) else local money = getPlayerMoney(playerSource) if( money < 1000000 ) then outputChatBox ( "You don't have enough money!", playerSource ) else local accname = getAccountName( acc ) local gangacc = addAccount( "gang-" ..name.."", "nisamkodkucejermiseoce" ) setAccountData ( gangacc,"leader",accname ) setAccountData ( gangacc,"name",name ) setAccountData ( acc,"gang","gang-" ..name.."" ) local team = createTeam(name) setPlayerTeam" class="kw6">setPlayerTeam" class="kw6">setPlayerTeam" class="kw6">setPlayerTeam( playerSource, team ) takePlayerMoney( playerSource, 1000000 ) setAccountData ( gangacc,"members",1 ) outputChatBox ( "Gang "..name.." sucesfully created!", playerSource ) end end end end function invite( playerSource, commandName, name ) local acc = getPlayerAccount ( playerSource ) local gang = getAccountData( acc,"gang") if( gang ) then local gangacc = getAccount(gang) local gangname = getAccountData( gangacc,"name") local gangleader = getAccountData( gangacc,"leader") if(leader==acc) then player = getPlayerFromName( name ) if(player) then outputChatBox ( "Tou have been invited to join "..gangname.." .use /gangaccept to accept this gang!", player ) local playeracc = getPlayerAccount ( player ) setAccountData(playeracc,"invite","gang-"..name.."") else outputChatBox ( "Player "..name.." doesn't exist", playerSource ) end else outputChatBox ( "You aren't leader of this gang!", playerSource ) end end end function accept( playerSource ) local acc = getPlayerAccount ( playerSource ) local gang = getAccountData( acc,"gang") if(gang) then outputChatBox ( "You already have a gang, use /gangleave to leave it!", playerSource ) else gang = getAccountData( acc,"invite") if(invite) then local gangacc = getAccount(gang) local gangname = getAccountData( gangacc,"name") local members = getAccountData ( gangacc,"members") setAccountData ( acc,"gang",gang ) setPlayerTeam" class="kw6">setPlayerTeam" class="kw6">setPlayerTeam" class="kw6">setPlayerTeam( playerSource, team ) members = members + 1 setAccountData (gangacc,"members",members) outputChatBox ( "You joind in gang "..gangname.." !", playerSource ) else outputChatBox ( "You haven't been invited in any gang!", playerSource ) end end end function leave( playerSource ) local acc = getPlayerAccount ( playerSource ) local gang = getAccountData( acc,"gang") local gangacc = getAccount(gang) local gangname = getAccountData( gangacc,"name") if(gang) then outputChatBox ( "You leaved gang "..gangname.."!", playerSource ) local members = getAccountData ( gangacc,"members") members = members - 1 setAccountData (gangacc,"members",members) setAccountData ( acc,"gang","") else outputChatBox ( "You don't have a gang!", playerSource ) end end function kick( playerSource, commandName, name ) local acc = getPlayerAccount ( playerSource ) local gang = getAccountData( acc,"gang") if ( gang ) then local gangacc = getAccount(gang) local gangname = getAccountData( gangacc,"name") local gangleader = getAccountData( gangacc,"leader") if(leader==acc) then player = getPlayerFromName( name ) if(player) then outputChatBox ( "You have been kicked from gang "..gangname.."!", player ) outputChatBox ( "You kicked "..name.." from gang!", player ) local members = getAccountData ( gangacc,"members") members = members - 1 setAccountData (gangacc,"members",members) setAccountData ( acc,"gang","") else outputChatBox ( "Player "..name.." doesn't exist", playerSource ) end else outputChatBox ( "You aren't leader of this gang!", playerSource ) end end end function onPlayerLogin ( ) local acc = getPlayerAccount ( source ) local gang = getAccountData( acc,"gang") if ( gang ) then local gangacc = getAccount(gang) local gangname = getAccountData( gangacc,"name") local team = getTeamFromName ( gangname ) setPlayerTeam" class="kw6">setPlayerTeam" class="kw6">setPlayerTeam" class="kw6">setPlayerTeam( source, team ) end end addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) addCommandHandler ( "gangcreate", create ) addCommandHandler ( "ganginvite", invite ) addCommandHandler ( "gangaccept", accept ) addCommandHandler ( "gangleave", leave ) addCommandHandler ( "gangkick", kick ) So, i fixed errors, wasnt tested the things... if i did gangcreate 123 then there were errors.. acces denied @add account line 16 :17: Bad argument @ setAccountData :18: Bad argument @ setAccountData :21: Bad argument @ setPlayerTeam ERROR: script.. .lua:21: attempt to call global 'kw6' ( a nil value ) So? U can check on Link to comment
Spajk Posted May 16, 2011 Author Share Posted May 16, 2011 ok, I had some "code" errors but I fixed them here's the code http://pastebin.com/zeHH16Yv I still have a lot of bug's so I am asking scripters to try making this thing to work Link to comment
Castillo Posted May 16, 2011 Share Posted May 16, 2011 I'm afraid i don't get your script, what do you want to do? create a gang and add the gang data to his/her account? because here you are adding an account with the gang name o,o. Link to comment
Moderators Citizen Posted May 17, 2011 Moderators Share Posted May 17, 2011 :21: Bad argument @ setPlayerTeamERROR: script.. .lua:21: attempt to call global 'kw6' ( a nil value ) Lol it's just a forum bug, when you want to show setPlayerTeam in lua syntax. I saw your script quickly and I don't find any error. I'll test it soon. Link to comment
Spajk Posted May 17, 2011 Author Share Posted May 17, 2011 Ok, I fixed some bugs, but I have problem with leave cmd [2011-05-17 10:33:56] WARNING: gang\gang.lua:76: Bad argument @ 'getAccountData' [2011-05-17 10:33:56] ERROR: gang\gang.lua:77: attempt to concatenate local 'gangname' (a boolean value) [2011-05-17 10:34:18] WARNING: gang\gang.lua:76: Bad argument @ 'getAccountData' [2011-05-17 10:34:18] ERROR: gang\gang.lua:77: attempt to concatenate local 'gangname' (a boolean value) The new code : http://pastebin.com/NsZHaEb2 @Solidsnake Yes, I am using MTA account system for gang accounts, I could use xml files, but I think this is easier And account name format is gang-gangname Link to comment
Spajk Posted May 17, 2011 Author Share Posted May 17, 2011 I give up I will use Solidsnake's gang system Link to comment
GerardWay Posted May 23, 2011 Share Posted May 23, 2011 I give up I will use Solidsnake's gang system Sp@jk please do not double post, instead use the edit button. thank you 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