Jump to content

function error


Monty

Recommended Posts

sorry what's wrong in this function

    function joinSAPD() 
        if (isGuestAccount(getPlayerAccount(source)) == false) then 
            local playeraccount = getPlayerAccount (source) 
            if not getElementData(source,"Occupation") == "police" then 
                setPlayerTeam(source,SAPDteam) 
                setElementModel(source, 280) 
                giveWeapon ( source, 3 ) 
                if getElementData(source, "arrest") == 0 then 
                setElementData(source, "arrest", "1") 
                setElementData(source, "Occupation", "police", true) 
                outputChatBox("You are now policeman.",source,0,255,0) 
            else 
                outputChatBox("Error: You already have this work",source,255,0,0) 
            end 
        else 
            outputChatBox ('Error: Please login or register!',source,255,255,255,true) 
        end 
         if getElementData(source, "arrest") == 0 then 
                setElementData(source, "arrest", "1") 
        end         
    end 
    addEvent("setSAPD", true) 
    addEventHandler("setSAPD",root,joinSAPD) 

Link to comment
sorry what's wrong in this function
   
  
  

setPlayerTeam(source,SAPDteam) 
  

setPlayerTeam(source,getTeamFromName(SAPDteam)) 
  

It's wrong the same way.

addEvent( 'setSAPD', true ) 
  
addEventHandler( 'setSAPD', root, 
    function( ) 
        local pAccount = getPlayerAccount( source ) 
        if( pAccount not isGuestAccount( pAccount ) ) then 
            if( getElementData( source, 'Occupation' ) ~= 'police' ) then 
                setPlayerTeam( source, getTeamFromName( 'Police' ) ) -- change 'Police' to the team name 
                setElementModel( source, 280 ) 
                giveWeapon( source, 3 ) 
                -- 
                if( getElementData( source, 'arrest' ) == 0 ) then 
                    setElementData( source, 'arrest', 1 ) 
                    setElementData( source, 'Occupation', 'police', true ) 
                    outputChatBox( 'You are now a Policeman!', source, 0, 255, 0, false ) 
                else 
                    outputChatBox( 'Error: You already have this work!', source, 255, 0, 0, false ) 
                end 
            else 
                outputChatBox( 'Error: Please login or register!', source, 255, 255, 255, false ) 
            end 
            if( getElementData( source, 'arrest' ) == 0 ) then 
                setElementModel( source, 'arrest', 1 ) 
            end 
        end 
    end 
) 

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...