Jump to content

I need someone to test the script


Spajk

Recommended Posts

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
  
  
  
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
  • Moderators
:21: Bad argument @ setPlayerTeam

ERROR: 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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...