LooF
Wiek: 22 Na forum: 2495 dni Posty: 4
Nick w MP: LooF
Witam,
ostatnio zajmuje si? skryptami na serwerze, lecz za ?adne skarby nie wiem jak to poprawnie z edytowa?, aby poprawnie ten skrypt dzia?a?.
Jest to skrypt "elections" - na cliencie i serverze, lecz client nie dzia?a, oto skrypt clienta:
GUIEditor = {
button = {},
window = {},
label = {},
combobox = {}
}
function electionsGUI ()
if isElement ( GUIEditor . window [ 1 ]) then return false end
GUIEditor . window [ 1 ] = guiCreateWindow ( 579 , 295 , 316 , 191 , "Wybory - 17.11.2019" , false )
guiWindowSetSizable ( GUIEditor . window [ 1 ], false )
GUIEditor . button [ 1 ] = guiCreateButton ( 0.09 , 0.68 , 0.34 , 0.24 , "G?osuj" , true , GUIEditor . window [ 1 ])
addEventHandler ( "onClientGUIClick" , GUIEditor . button [ 1 ], function ()
local selection = guiGetText ( GUIEditor . combobox [ 1 ])
if selection == "Wybierz" then return false end
doVote ( selection )
end , false )
GUIEditor . button [ 2 ] = guiCreateButton ( 0.55 , 0.68 , 0.34 , 0.24 , "Zamknij" , true , GUIEditor . window [ 1 ])
addEventHandler ( "onClientGUIClick" , GUIEditor . button [ 2 ], function ()
if isElement ( GUIEditor . window [ 1 ]) then destroyElement ( GUIEditor . window [ 1 ]) end
end , false )
GUIEditor . label [ 1 ] = guiCreateLabel ( 0.05 , 0.12 , 0.89 , 0.12 , "Wybierz kandydata i kliknij `G?osuj`" , true , GUIEditor . window [ 1 ])
GUIEditor . combobox [ 1 ] = guiCreateComboBox ( 0.05 , 0.26 , 0.89 , 0.41 , "Wybierz..." , true , GUIEditor . window [ 1 ])
guiComboBoxAddItem ( GUIEditor . combobox [ 1 ], "Daryl Dixon" )
guiComboBoxAddItem ( GUIEditor . combobox [ 2 ], "Justin Bimber" )
guiComboBoxAddItem ( GUIEditor . combobox [ 3 ], "Ebenezer Ferreri" )
guiComboBoxAddItem ( GUIEditor . combobox [ 4 ], "Victor Rosen" )
end
addEvent ( "elections:votegui" , true )
addEventHandler ( "elections:votegui" , getLocalPlayer (), electionsGUI )
-- addCommandHandler ( "electiongui" , electionsGUI )
function doVote ( selection )
local alreadyVoted = getElementData ( getLocalPlayer (), "electionsvoted" )
if alreadyVoted == 1 then
outputChatBox ( "Ju? odda?e? g?os!" )
if isElement ( GUIEditor . window [ 1 ]) then destroyElement ( GUIEditor . window [ 1 ]) end
return false
end
local currentVotes = getElementData ( resourceRoot , "elections:votes" )
local vote = nil
for k , v in pairs ( currentVotes ) do
if v [ "idelections" ] == selection then
vote = k
end
end
currentVotes [ vote ][ "Votes" ] = tonumber ( currentVotes [ vote ][ "Votes" ]) + 1
setElementData ( resourceRoot , "elections:votes" , currentVotes )
triggerServerEvent ( "elections:refresh" , resourceRoot , selection , currentVotes [ vote ][ "Votes" ], getLocalPlayer ())
end
A b??d taki: Kod: ERROR: elections/wybory_c.lua:51: attempt to index field '?' (a nil value)
Linia 51: currentVotes [ vote ][ "Votes" ] = tonumber ( currentVotes [ vote ][ "Votes" ]) + 1
Wie kto? jak to naprawi?? By?bym wdzi?czny <3
[ Dodano : 2019-11-17, 20:02 ]
Ca?y czas czekam