Jump to content

Will this work?


Spajk

Recommended Posts

Ok, a am new to LUA and I need help.

Can someone tell me if I have some "code" mistake :)

function free( player ) 
    setPlayerWantedLevel ( player, 0 ) 
end 
  
function playerDamage ( attacker, weapon, bodypart, loss ) --when a player is damaged 
    if ( bodypart == 7 or bodypart==8 ) then 
            setPedAnimation( source, "ped", "WOMAN_walknorm", 5000) 
    end 
    local swat = getTeamFromName("SWAT") 
    local fbi = getTeamFromName("FBI") 
    local officer = getTeamFromName("Police officer") 
    local tc = getTeamFromName("Traffic control") 
    local team = getPlayerTeam" class="kw2">getPlayerTeam" class="kw2">getPlayerTeam" class="kw2">getPlayerTeam" class="kw2">getPlayerTeam" class="kw2">getPlayerTeam ( source ) 
    If ( weapon == 3 ) then 
        if(team==swat or team==fbi or team==officer or team==tc) then 
        local stars = getPlayerWantedLevel ( source ) 
        local time - stars*10 
        setAccountData ( account, "rpg.jtime", time ) 
         
        setTimer(free,time*1000,1,source) 
        end 
    end      
end 
  
function onPlayerQuit ( ) 
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) then 
            local playerstars = getPlayerWantedLevel ( source ) 
            setAccountData ( playeraccount, "rpg.wstars", playerstars ) 
      end 
end 
  
function onPlayerLogin ( ) 
    local playeraccount = getPlayerAccount ( source ) 
    if ( playeraccount ) then 
        local playerstars = getAccountData ( playeraccount, "rpg.wstars" ) 
        if ( playerstars ) then 
            setPlayerWantedLevel ( source, playerstars ) 
        end 
    end 
end 
  
function registeracc( playerSource, commandName, user, pass ) 
    local account = getPlayerAccount ( playerSource ) 
    if isGuestAccount ( account ) then 
        If getAccount( user ) 
            outputChatBox ( "Account name alreaady exist.", playerSource ) 
        else 
            addAccount( user, pass ) 
    `       outputChatBox ( "Account" ..user.. "successfully created with password" ..pass.. ".", playerSource ) 
        end 
    else 
        outputChatBox ( "You already have account.", playerSource ) 
    end 
end 
  
addCommandHandler ( "register", registeracc ) 
addEventHandler ( "onPlayerDamage", getRootElement (), playerDamage ) 
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) 
addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin )  
  
  
  

Link to comment

Yes, you do.

function free( player ) 
    setPlayerWantedLevel ( player, 0 ) 
end 
  
function playerDamage ( attacker, weapon, bodypart, loss ) --when a player is damaged 
    if ( bodypart == 7 or bodypart==8 ) then 
            setPedAnimation( source, "ped", "WOMAN_walknorm", 5000) 
    end 
    local swat = getTeamFromName("SWAT") 
    local fbi = getTeamFromName("FBI") 
    local officer = getTeamFromName("Police officer") 
    local tc = getTeamFromName("Traffic control") 
    local team = getPlayerTeam( source ) 
    if ( weapon == 3 ) then -- It's not If, it's if, with lowercase. 
        if(team==swat or team==fbi or team==officer or team==tc) then 
        local stars = getPlayerWantedLevel ( source ) 
        local time - stars*10 
        setAccountData ( account, "rpg.jtime", time ) 
        setTimer(free,time*1000,1,source) 
        end 
    end     
end 
  
function onPlayerQuit ( ) 
      local playeraccount = getPlayerAccount ( source ) 
      if ( playeraccount ) then 
            local playerstars = getPlayerWantedLevel ( source ) 
            setAccountData ( playeraccount, "rpg.wstars", playerstars ) 
      end 
end 
  
function onPlayerLogin ( ) 
    local playeraccount = getPlayerAccount ( source ) 
    if ( playeraccount ) then 
        local playerstars = getAccountData ( playeraccount, "rpg.wstars" ) 
        if ( playerstars ) then 
            setPlayerWantedLevel ( source, playerstars ) 
        end 
    end 
end 
  
function registeracc( playerSource, commandName, user, pass ) 
    local account = getPlayerAccount ( playerSource ) 
    if isGuestAccount ( account ) then 
        If getAccount( user ) 
            outputChatBox ( "Account name alreaady exist.", playerSource ) 
        else 
            addAccount( user, pass ) 
    `       outputChatBox ( "Account" ..user.. "successfully created with password" ..pass.. ".", playerSource ) 
        end 
    else 
        outputChatBox ( "You already have account.", playerSource ) 
    end 
end 
  
addCommandHandler ( "register", registeracc ) 
addEventHandler ( "onPlayerDamage", getRootElement (), playerDamage ) 
addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) 
addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) 

Apart from that, i think nothing else, busy to check it all.

Link to comment
  
  
        if ( weapon == 3 ) then -- It's not If, it's if, with lowercase. 
            if (team==swat or team==fbi or team==officer or team==tc) then 
            local stars = getPlayerWantedLevel ( source ) 
--[[>]]     local time = stars*10 -- time =, not time - 
--[[>]]     setAccountData(account, "rpg.jtime", time) -- is account variable set? 
            setTimer(free,time*1000,1,source) 
            end 
        end     
    end 
      
    function onPlayerQuit ( ) 
          local playeraccount = getPlayerAccount ( source ) 
          if ( playeraccount ) then 
                local playerstars = getPlayerWantedLevel ( source ) 
                setAccountData ( playeraccount, "rpg.wstars", playerstars ) 
          end 
    end 
      
    function onPlayerLogin ( ) 
        local playeraccount = getPlayerAccount ( source ) 
        if ( playeraccount ) then 
            local playerstars = getAccountData ( playeraccount, "rpg.wstars" ) 
            if ( playerstars ) then 
                setPlayerWantedLevel ( source, playerstars ) 
            end 
        end 
    end 
      
    function registeracc( playerSource, commandName, user, pass ) 
        local account = getPlayerAccount ( playerSource ) 
        if isGuestAccount ( account ) then 
--[[>]]     if getAccount( user ) then -- same thing with if, not If, also 'then' was missing 
                outputChatBox ( "Account name already exists.", playerSource ) 
            else 
                addAccount( user, pass ) 
        `       outputChatBox ( "Account " ..user.. " successfully created with password " ..pass.. ".", playerSource ) 
            end 
        else 
            outputChatBox ( "You already have account.", playerSource ) 
        end 
    end 
      
    addCommandHandler ( "register", registeracc ) 
    addEventHandler ( "onPlayerDamage", getRootElement (), playerDamage ) 
    addEventHandler ( "onPlayerQuit", getRootElement ( ), onPlayerQuit ) 
    addEventHandler ( "onPlayerLogin", getRootElement ( ), onPlayerLogin ) 

Link to comment
thank you very much :)

I don't understand this:

--[[>]] setAccountData(account, "rpg.jtime", time) -- is account variable set?

are you sure that "account" is an account?

i mean, maybe you forgot something like "local account = getPlayerAccount(source)"

Link to comment
thank you very much :)

I don't understand this:

--[[>]] setAccountData(account, "rpg.jtime", time) -- is account variable set?

are you sure that "account" is an account?

i mean, maybe you forgot something like "local account = getPlayerAccount(source)"

thanks on that too, I forgot to add that :)

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