Jump to content

help me with grad


Dolinho

Recommended Posts

Posted

If I have one star wanted level for all Appeared a star, but if I have 2 or 3 will have all the same level as me.

why this is happening?

can someone help me?

function Mineirojob() 
if ( players ) then 
                for id, playeritem in ipairs(getElementsByType("player")) do  
local row = guiGridListAddRow ( grid ) 
                        guiGridListSetItemText ( grid, row, players, getPlayerName ( playeritem ) or "Sem dados", false, false ) 
                        guiGridListSetItemColor(grid,row,1,getPlayerNametagColor(playeritem)) 
                        cx,cy,cz = getElementPosition( playeritem ) 
                        guiGridListSetItemText (grid, row, location, getZoneName ( cx,cy,cz ) or "Sem dados", false, false ) 
                        guiGridListSetItemText ( grid, row, travel, getElementHealth ( playeritem ) or "Morto", false, false ) 
                        guiGridListSetItemText ( grid, row, team, getTeamName(getPlayerTeam(playeritem)) or "Sem Team", false, false ) 
                        guiGridListSetItemColor (grid, row, team, getTeamColor(getPlayerTeam(playeritem)) ) 
                        if (getPlayerWantedLevel(playeritem) == 0) then  
                        guiGridListSetItemText ( grid, row, level,"Esta limpo", false, false ) 
                        elseif (getPlayerWantedLevel(playeritem) == 1) then 
                        guiGridListSetItemText ( grid, row, level,"   1 Estrela", false, false ) 
                        elseif (getPlayerWantedLevel(playeritem) == 2) then 
                        guiGridListSetItemText ( grid, row, level,"   2 Estrela", false, false ) 
                        elseif (getPlayerWantedLevel(playeritem) == 3) then 
                        guiGridListSetItemText ( grid, row, level,"   3 Estrela", false, false ) 
                        elseif (getPlayerWantedLevel(playeritem) == 4) then 
                        guiGridListSetItemText ( grid, row, level,"   4 Estrela", false, false ) 
                        elseif (getPlayerWantedLevel(playeritem) == 5) then 
                        guiGridListSetItemText ( grid, row, level,"   5 Estrela", false, false ) 
                        elseif (getPlayerWantedLevel(playeritem) == 6) then 
                        guiGridListSetItemText ( grid, row, level,"   6 Estrela", false, false ) 
            end 
        end 
    end 
end 
addEventHandler("onClientResourceStart", getRootElement(), Mineirojob) 

Posted

That's because getPlayerWantedLevel when used client side, it only returns the wanted level of the local player.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Can anyone tell me if this is correct ?

Client:

guiGridListSetItemText ( grid, row, level, getElementData(playeritem,"wants"), false, false ) 

Server:

function SecondPlayerWanted (playeritem) 
for i,playeritem in ipairs (getElementsByType("player")) do 
if playeritem ~= source then 
local level = getPlayerWantedLevel(playeritem) 
setElementData(playeritem, "wants",level) 
end 
end 
end 
setTimer (test, 50, 0 ) 

Posted

That's highly inefficient, it's going to lag the server.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

  • Moderators
Posted

Especially line 5, will totally destroy the network traffic.

Always check if elementdata must be overwritten or not. Overwrite elementdata with the same value is stupid, unless you are editing the same elementdata key on the other side too.

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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