Jump to content

problem oO


Kenix

Recommended Posts

IDK but it not working :shock:

  
function setPlayerID( id,player ) 
    for i,v in ipairs(getElementsByType("player")) do 
        if getElementData(v,"ID") == id then 
            id = id+1 
        end 
    end 
    setElementData(player,"ID",tonumber(id))  
end 
  

debug: Bad argument @ 'setElementData' [Expected element at argument 1, got number '1']

Link to comment
This code seems to work fine, could you please mention the part/function where are you using this?

Ok dude

  
addEvent("spawnCharacter",true) 
addEventHandler("spawnCharacter",root, 
    function( playerSkin,charNumber ) 
            local result1 = executeSQLSelect ( "users1", "*", "user = '"..getAccountName( getPlayerAccount( source ) ).. "'" ) 
            local result2 = executeSQLSelect ( "users2", "*", "user = '"..getAccountName( getPlayerAccount( source ) ).. "'" ) 
            local result3 = executeSQLSelect ( "users3", "*", "user = '"..getAccountName( getPlayerAccount( source ) ).. "'" ) 
             
            local usersWeapons1 = executeSQLSelect ( "usersWeapons1", "*","user = '" .. getAccountName( getPlayerAccount( source ) ) .. "'") 
            local usersWeapons2 = executeSQLSelect ( "usersWeapons2", "*","user = '" .. getAccountName( getPlayerAccount( source ) ) .. "'") 
            local usersWeapons3 = executeSQLSelect ( "usersWeapons3", "*","user = '" .. getAccountName( getPlayerAccount( source ) ) .. "'") 
             
            local data =  getElementData( source,"selectChar") 
            if data == 1 then 
                if #result1 == 1 then 
                    setTimer(function( player ) 
                        setPlayerMoney(player,result1[1]['money']) 
                        spawnPlayer( player, result1[1]['x'], result1[1]['y'], result1[1]['z']) 
                        setElementHealth(player,result1[1]['health']) 
                        setPedArmor(player,result1[1]['armor'])  
                        setPlayerWantedLevel(player,result1[1]['wanted']) 
                        setElementModel(player,result1[1]['skin']) 
                        setElementDimension (player,result1[1]['dim']) 
                        setElementInterior (player,result1[1]['int']) 
                         
                        setCameraTarget(player,player) 
                        toggleAllControls ( player, true ) 
                        fadeCamera(player,true,1) 
                        setElementAlpha(player,255) 
                    end,300,1,source)    
                    setPlayerNametagColor ( source, result1[1]['r'], result1[1]['g'], result1[1]['b'] ) 
                    setElementData(source,"jailtime",result1[1]['jailtime']) 
                    setPedStat ( source, 69, result1[1]['stat0'] ) 
                    setPedStat ( source, 70, result1[1]['stat1'] ) 
                    setPedStat ( source, 71, result1[1]['stat2'] ) 
                    setPedStat ( source, 72, result1[1]['stat3'] ) 
                    setPedStat ( source, 73, result1[1]['stat4'] ) 
                    setPedStat ( source, 74, result1[1]['stat5'] ) 
                    setPedStat ( source, 75, result1[1]['stat6'] ) 
                    setPedStat ( source, 76, result1[1]['stat7'] ) 
                    setPedStat ( source, 77, result1[1]['stat8'] ) 
                    setPedStat ( source, 78, result1[1]['stat9'] ) 
                    setPedStat ( source, 79, result1[1]['stat10'] ) 
                else 
                    setTimer(function( player ) 
                        spawnPlayer(player,-1422.7177734375,-288.5537109375,14.1484375,136.47149658203,getElementData( player, "selectCharSkin"),0,0,nil) 
                        setCameraTarget(player,player) 
                        toggleAllControls ( player, true ) 
                        fadeCamera(player,true,1) 
                        setElementAlpha(player,255) 
                    end,300,1,source) 
                end  
                if not usersWeapons1 or #usersWeapons1 == 0 then return end 
                setTimer(function( player ) 
                    if  #usersWeapons1 > 0 then 
                        for index=1, #usersWeapons1 do  
                            if ( usersWeapons1[index]["weapons"] ) then 
                                giveWeapon(player,usersWeapons1[index]['weapons'],usersWeapons1[index]['ammo'] or 0,false) 
                            end 
                        end 
                    end 
                end,500,1,source)    
            elseif data == 2 then 
                if #result2 == 1 then 
                    setPlayerMoney(source,result2[1]['money']) 
                    setTimer(function( player ) 
                        spawnPlayer( player, result2[1]['x'], result2[1]['y'], result2[1]['z']) 
                        setElementHealth(player,result2[1]['health']) 
                        setPedArmor(player,result2[1]['armor'])  
                        setPlayerWantedLevel(player,result2[1]['wanted']) 
                        setElementModel(player,result2[1]['skin']) 
                        setElementDimension (player,result2[1]['dim']) 
                        setElementInterior (player,result2[1]['int']) 
                         
                        setCameraTarget(player,player) 
                        toggleAllControls ( player, true ) 
                        fadeCamera(player,true,1) 
                        setElementAlpha(player,255) 
                    end,300,1,source)    
                    setPlayerNametagColor ( source, result2[1]['r'], result2[1]['g'], result2[1]['b'] ) 
                    setElementData(source,"jailtime",result2[1]['jailtime']) 
                    setPedStat ( source, 69, result2[1]['stat0'] ) 
                    setPedStat ( source, 70, result2[1]['stat1'] ) 
                    setPedStat ( source, 71, result2[1]['stat2'] ) 
                    setPedStat ( source, 72, result2[1]['stat3'] ) 
                    setPedStat ( source, 73, result2[1]['stat4'] ) 
                    setPedStat ( source, 74, result2[1]['stat5'] ) 
                    setPedStat ( source, 75, result2[1]['stat6'] ) 
                    setPedStat ( source, 76, result2[1]['stat7'] ) 
                    setPedStat ( source, 77, result2[1]['stat8'] ) 
                    setPedStat ( source, 78, result2[1]['stat9'] ) 
                    setPedStat ( source, 79, result2[1]['stat10'] ) 
                else 
                    setTimer(function( player ) 
                        spawnPlayer(player,-1422.7177734375,-288.5537109375,14.1484375,136.47149658203,getElementData( player, "selectCharSkin"),0,0,nil) 
                        setCameraTarget(player,player) 
                        toggleAllControls ( player, true ) 
                        fadeCamera(player,true,1) 
                        setElementAlpha(player,255) 
                    end,300,1,source) 
                end 
                if not usersWeapons2 or #usersWeapons2 == 0 then return end 
                setTimer(function( player ) 
                    if  #usersWeapons2 > 0 then 
                        for index=1, #usersWeapons2 do  
                            if ( usersWeapons2[index]["weapons"] ) then 
                                giveWeapon(player,usersWeapons2[index]['weapons'],usersWeapons2[index]['ammo'] or 0,false) 
                            end 
                        end 
                    end 
                end,500,1,source)    
            elseif data == 3 then 
                if #result3 == 1 then 
                    setPlayerMoney(source,result3[1]['money']) 
                    setTimer(function( player ) 
                        spawnPlayer( player, result3[1]['x'], result3[1]['y'], result3[1]['z']) 
                        setElementHealth(player,result3[1]['health']) 
                        setPedArmor(player,result3[1]['armor'])  
                        setPlayerWantedLevel(player,result3[1]['wanted']) 
                        setElementModel(player,result3[1]['skin']) 
                        setElementDimension (player,result3[1]['dim']) 
                        setElementInterior (player,result3[1]['int']) 
                         
                        setCameraTarget(player,player) 
                        toggleAllControls ( player, true ) 
                        fadeCamera(player,true,1) 
                        setElementAlpha(player,255) 
                    end,300,1,source)    
                    setPlayerNametagColor ( source, result3[1]['r'], result3[1]['g'], result3[1]['b'] ) 
                    setElementData(source,"jailtime",result3[1]['jailtime']) 
                    setPedStat ( source, 69, result3[1]['stat0'] ) 
                    setPedStat ( source, 70, result3[1]['stat1'] ) 
                    setPedStat ( source, 71, result3[1]['stat2'] ) 
                    setPedStat ( source, 72, result3[1]['stat3'] ) 
                    setPedStat ( source, 73, result3[1]['stat4'] ) 
                    setPedStat ( source, 74, result3[1]['stat5'] ) 
                    setPedStat ( source, 75, result3[1]['stat6'] ) 
                    setPedStat ( source, 76, result3[1]['stat7'] ) 
                    setPedStat ( source, 77, result3[1]['stat8'] ) 
                    setPedStat ( source, 78, result3[1]['stat9'] ) 
                    setPedStat ( source, 79, result3[1]['stat10'] ) 
                else 
                    setTimer(function( player ) 
                        spawnPlayer(player,-1422.7177734375,-288.5537109375,14.1484375,136.47149658203,getElementData( player, "selectCharSkin"),0,0,nil) 
                        setCameraTarget(player,player) 
                        toggleAllControls ( player, true ) 
                        fadeCamera(player,true,1) 
                        setElementAlpha(player,255) 
                    end,300,1,source) 
                end 
                if not usersWeapons3 or #usersWeapons3 == 0 then return end 
                setTimer(function( player ) 
                    if  #usersWeapons3 > 0 then 
                        for index=1, #usersWeapons3 do  
                            if ( usersWeapons3[index]["weapons"] ) then 
                                giveWeapon(player,usersWeapons3[index]['weapons'],usersWeapons3[index]['ammo'] or 0,false) 
                            end 
                        end 
                    end 
                end,500,1,source)    
            end 
            setElementData(source,"isLogged",true) 
            setPlayerID(source,1) 
            local usersLogged = executeSQLSelect ( "usersLogged", "*","accountName = '" .. getAccountName( getPlayerAccount( source ) ) .. "'") 
            if not usersLogged or #usersLogged == 0 then 
                local var = "true"  
                executeSQLInsert ( "usersLogged", "'"..getAccountName( getPlayerAccount( source ) ).."','"..var.."'") 
            else 
                local var = "true"  
                executeSQLUpdate( "usersLogged", "accountName = '"..getAccountName( getPlayerAccount( source ) ).."',bool = '"..var.."'") 
            end 
            outputChatBox("* "..getPlayerName( source ).." вошёл на сервер",root,102,204,0,false) 
    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...