Jump to content

Where problems tostring ?


-ffn-python

Recommended Posts

Posted

Client.lua

  
  
local screenW, screenH = guiGetScreenSize() 
  
addEvent("onClientPythonStats", true ) 
addEventHandler("onClientPythonStats", root, Test) 
    function Test(kazanma) 
    local Nick = "PlayerNick:"..getPlayerName(localPlayer) 
    local kazanma = "Maps Win:"..tostring(kazanma) 
        dxDrawRectangle(screenW * 0.2709, screenH * 0.1966, screenW * 0.4458, screenH * 0.5247, tocolor(0, 0, 0, 179), false) 
        dxDrawText("PLAYER STATS SYSTEM BY PYTHON", screenW * 0.2826, screenH * 0.1966, screenW * 0.6918, screenH * 0.2357, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false) 
        dxDrawText(kazanma, screenW * 0.2753, screenH * 0.3164, screenW * 0.5322, screenH * 0.3529, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false) 
        dxDrawText(Nick, screenW * 0.2753, screenH * 0.2799, screenW * 0.5322, screenH * 0.3164, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false) 
    end 
addEventHandler("onClientRender", root, Test) 

server.lua

    addEvent("onPythonStats", true) 
    addEventHandler("onPythonStats", root, 
    function() 
        local kazanma = getElementData(client, "wins") 
        triggerClientEvent(client, "onClientPythonStats", client, kazanma) 
    end) 

Are You Find Scripter ?

Contact Me Web Skype:Click To Skype

Posted
  
----- # client 
local screenW, screenH = guiGetScreenSize() 
  
    function Test(kazanma) 
    local Nick = "PlayerNick:"..getPlayerName(localPlayer) 
    local kazanma = "Maps Win:"..tostring(kazanma) 
        dxDrawRectangle(screenW * 0.2709, screenH * 0.1966, screenW * 0.4458, screenH * 0.5247, tocolor(0, 0, 0, 179), false) 
        dxDrawText("PLAYER STATS SYSTEM BY PYTHON", screenW * 0.2826, screenH * 0.1966, screenW * 0.6918, screenH * 0.2357, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false) 
        dxDrawText(kazanma, screenW * 0.2753, screenH * 0.3164, screenW * 0.5322, screenH * 0.3529, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false) 
        dxDrawText(Nick, screenW * 0.2753, screenH * 0.2799, screenW * 0.5322, screenH * 0.3164, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false) 
    end 
addEventHandler("onClientRender", root, Test) 
addEvent("onClientPythonStats", true ) 
addEventHandler("onClientPythonStats", root, Test) 

Discord: LoOs#1111

_____________________________

76561198299431254.png

Posted
Client.lua

server.lua

    addEvent("onPythonStats", true) 
    addEventHandler("onPythonStats", root, 
    function() 
        local kazanma = getElementData(client, "wins") 
        triggerClientEvent(client, "onClientPythonStats", client, kazanma) 
    end) 

Are You Find Scripter ?

Contact Me Web Skype:Click To Skype

Posted
Client.lua
function Test(kazanma) 
     ... 
end 
addEventHandler("onClientRender", root, Test) 

You are using onClientRender and put a parameter in function. LOL!

Please look onClientRender event. This event isn't have any parameters.

You can use it: (If you set wins data)

local kazanma = "Maps Win:"..tostring(getElementData(playerElement --[[if you want to local player, use localPlayer]], "wins")) 

Posted (edited)
local screenW, screenH = guiGetScreenSize() 
  
    function Test(kazanma) 
    local Nick = "PlayerNick:"..getPlayerName(localPlayer) 
        dxDrawRectangle(screenW * 0.2709, screenH * 0.1966, screenW * 0.4458, screenH * 0.5247, tocolor(0, 0, 0, 179), false) 
        dxDrawText("PLAYER STATS SYSTEM BY PYTHON", screenW * 0.2826, screenH * 0.1966, screenW * 0.6918, screenH * 0.2357, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false) 
        dxDrawText("Maps Win:"..getElementData(getLocalPlayer(),"wins"), screenW * 0.2753, screenH * 0.3164, screenW * 0.5322, screenH * 0.3529, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false) 
        dxDrawText(Nick, screenW * 0.2753, screenH * 0.2799, screenW * 0.5322, screenH * 0.3164, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false) 
    end 
addEventHandler("onClientRender", root, Test) 
addEvent("onClientPythonStats", true ) 
addEventHandler("onClientPythonStats", root, Test) 

Why u use setElementData in server side while you can use it in client side? It's shared function

Also here is test code for map wins

client side

function hello() 
setElementData(getLocalPlayer(),"wins", getElementData(getLocalPlayer(),"wins") + 1) 
end 
addCommandHandler("givewins",hello) 

Edited by Guest
2vjs7it.jpg
  • Moderators
Posted
Why u use setElementData in server side while you can use it in client side? It's shared function

Because it is stupid to give clients rights for editing their score. This is what serverside and serverside only should do.

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

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted
local screenW, screenH = guiGetScreenSize() 
  
    function Test(kazanma) 
    local Nick = "PlayerNick:"..getPlayerName(localPlayer) 
local Test = "MapsWin:"..getElementData(getLocalPlayer(),"wins") 
        dxDrawRectangle(screenW * 0.2709, screenH * 0.1966, screenW * 0.4458, screenH * 0.5247, tocolor(0, 0, 0, 179), false) 
        dxDrawText("PLAYER STATS SYSTEM BY PYTHON", screenW * 0.2826, screenH * 0.1966, screenW * 0.6918, screenH * 0.2357, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false) 
        dxDrawText(Test, screenW * 0.2753, screenH * 0.3164, screenW * 0.5322, screenH * 0.3529, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false) 
        dxDrawText(Nick, screenW * 0.2753, screenH * 0.2799, screenW * 0.5322, screenH * 0.3164, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false) 
    end 
addEventHandler("onClientRender", root, Test) 
addEvent("onClientPythonStats", true ) 
addEventHandler("onClientPythonStats", root, Test) 

Why u use setElementData in server side while you can use it in client side? It's shared function

Also here is test code for map wins

client side

function hello() 
setElementData(getLocalPlayer(),"wins", getElementData(getLocalPlayer(),"wins") + 1) 
end 
addCommandHandler("givewins",hello) 

don't work. value error .

rVkONP.png

Are You Find Scripter ?

Contact Me Web Skype:Click To Skype

Posted
local screenW, screenH = guiGetScreenSize() 
  
    function Test(kazanma) 
    local Nick = "PlayerNick:"..getPlayerName(localPlayer) 
local Test = "MapsWin:"..getElementData(getLocalPlayer(),"wins") 
        dxDrawRectangle(screenW * 0.2709, screenH * 0.1966, screenW * 0.4458, screenH * 0.5247, tocolor(0, 0, 0, 179), false) 
        dxDrawText("PLAYER STATS SYSTEM BY PYTHON", screenW * 0.2826, screenH * 0.1966, screenW * 0.6918, screenH * 0.2357, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false) 
        dxDrawText(Test, screenW * 0.2753, screenH * 0.3164, screenW * 0.5322, screenH * 0.3529, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false) 
        dxDrawText(Nick, screenW * 0.2753, screenH * 0.2799, screenW * 0.5322, screenH * 0.3164, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false) 
    end 
addEventHandler("onClientRender", root, Test) 
addEvent("onClientPythonStats", true ) 
addEventHandler("onClientPythonStats", root, Test) 

Why u use setElementData in server side while you can use it in client side? It's shared function

Also here is test code for map wins

client side

function hello() 
setElementData(getLocalPlayer(),"wins", getElementData(getLocalPlayer(),"wins") + 1) 
end 
addCommandHandler("givewins",hello) 

don't work. value error .

rVkONP.png

hmm that isn't my code o.O i didn't add that thing at line 5

2vjs7it.jpg
Posted (edited)

Shows as Winning Number 0 :?

New Code.

    local screenW, screenH = guiGetScreenSize() 
      
        function Test(kazanma) 
        local Nick = "PlayerNick:"..getPlayerName(localPlayer) 
            local Test = "MapsWin:"..tostring(kazanma) 
            dxDrawRectangle(screenW * 0.2709, screenH * 0.1966, screenW * 0.4458, screenH * 0.5247, tocolor(0, 0, 0, 179), false) 
            dxDrawText("PLAYER STATS SYSTEM BY PYTHON", screenW * 0.2826, screenH * 0.1966, screenW * 0.6918, screenH * 0.2357, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false) 
            dxDrawText(Test, screenW * 0.2753, screenH * 0.3164, screenW * 0.5322, screenH * 0.3529, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false) 
            dxDrawText(Nick, screenW * 0.2753, screenH * 0.2799, screenW * 0.5322, screenH * 0.3164, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false) 
        end 
    addEventHandler("onClientRender", root, Test) 
    addEvent("onClientPythonStats", true ) 
    addEventHandler("onClientPythonStats", root, Test) 
  
-- SERVER SIDE 
    function hello() 
    setElementData(getLocalPlayer(),"wins", getElementData(getLocalPlayer(),"wins") + 1) 
    end 
    addCommandHandler("givewins",hello) 

My old Code.

Client.lua

  
  
local screenW, screenH = guiGetScreenSize() 
  
addEvent("onClientPythonStats", true ) 
addEventHandler("onClientPythonStats", root, Test) 
    function Test(kazanma) 
    local Nick = "PlayerNick:"..getPlayerName(localPlayer) 
    local kazanma = "Maps Win:"..tostring(kazanma) 
        dxDrawRectangle(screenW * 0.2709, screenH * 0.1966, screenW * 0.4458, screenH * 0.5247, tocolor(0, 0, 0, 179), false) 
        dxDrawText("PLAYER STATS SYSTEM BY PYTHON", screenW * 0.2826, screenH * 0.1966, screenW * 0.6918, screenH * 0.2357, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false) 
        dxDrawText(kazanma, screenW * 0.2753, screenH * 0.3164, screenW * 0.5322, screenH * 0.3529, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false) 
        dxDrawText(Nick, screenW * 0.2753, screenH * 0.2799, screenW * 0.5322, screenH * 0.3164, tocolor(255, 255, 255, 255), 1.00, "bankgothic", "left", "top", false, false, false, false, false) 
    end 
addEventHandler("onClientRender", root, Test) 

server.lua

    addEvent("onPythonStats", true) 
    addEventHandler("onPythonStats", root, 
    function() 
        local kazanma = getElementData(client, "wins") 
        triggerClientEvent(client, "onClientPythonStats", client, kazanma) 
    end) 

Edited by Guest

Are You Find Scripter ?

Contact Me Web Skype:Click To Skype

Posted

There's no point in sending the wins with triggerClientEvent, the client-side script is already using getElementData to get the wins.

The problem is not in the script, the 'wins' element data is false, hence why the script needed a fault-safe value, which is zero in this case.

Business System viewtopic.php?f=108&t=35797

Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726

SQLite Tutorial viewtopic.php?f=148&t=38203

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