Hi I'm learning scripting very slowly and a resource I'm using has an error (which is in the title).
function KeyBind() -- bind the key for all players.
if get("g_vote") == 'true' then
local players = getElementsByType("player")
local pcount = getPlayerCount()
triggerClientEvent("onGMStop", getRootElement())
if string.find(getMapName(), get('filterword'), 1, true) then
outputDebugString("DD Detected, Halting the ghostmode voting.")
else
executeSQLQuery("DELETE FROM GmBlockList")
VoteCount = 0
for k,v in ipairs (players) do
bindKey(v,"g","down",addVote)
setElementData( v, "overrideCollide.uniqueblah", nil, false )
end
outputChatBox("Ghostmode Disabled by Server",getRootElement(),255,0,0)
StartElement()
end
end
end
addEventHandler("onMapStarting",getRootElement(),KeyBind)
function KeyUnBind(newStateName,oldStateName)
if get("g_vote") == 'true' then
if newStateName == "Running" then
local players = getElementsByType("player")
for k,v in ipairs (players) do
unbindKey(v,"g","down",addVote)
end
executeSQLQuery("DELETE FROM GmBlockList")
triggerClientEvent("onGMStop", getRootElement())
if VoteCount >= ReqPlayers() then
outputChatBox("*Ghostmode: Voting for ghostmode passed!",root,162,82,201)
for k,thePlayer in ipairs(getElementsByType('player')) do
setElementData( thePlayer, "overrideCollide.uniqueblah", 0, true )
end
else
--[[for k,thePlayer in ipairs(getElementsByType('player')) do
setElementData( thePlayer, "overrideCollide.uniqueblah", 255, false )
end]]--
outputChatBox("*Ghostmode: Voting for ghostmode failed!",root,162,82,201)
end
end
end
end
addEvent("onRaceStateChanging")
addEventHandler("onRaceStateChanging",getRootElement(),KeyUnBind)
function addVote(keyPresser)
local serial = getPlayerSerial(keyPresser)
local serialcheck = executeSQLSelect ( "GmBlockList", "serial","serial = '" .. serial .. "'")
if ( type( serialcheck ) == "table" and #serialcheck == 0 ) or not serialcheck then
executeSQLInsert ( "GmBlockList", "'"..serial.."'")
VoteCount = VoteCount + 1
triggerClientEvent(getRootElement(),"UpdateCount", getRootElement(),VoteCount,ReqPlayers())
else
outputChatBox("You have already voted for Ghostmode!",keyPresser,255,0,0)
end
end
function ReqPlayers()
local pcount = getPlayerCount()
if pcount == 1 then
reqPlayers = 1
elseif pcount > 1 and pcount < 4 then
reqPlayers = 2
elseif pcount > 3 and pcount < 7 then
reqPlayers = 3
elseif pcount > 6 and pcount < 10 then
reqPlayers = 5
elseif pcount > 9 and pcount < 15 then
reqPlayers = 7
elseif pcount > 14 and pcount < 21 then
reqPlayers = 12
elseif pcount > 20 and pcount < 26 then
reqPlayers = 17
elseif pcount > 25 then
reqPlayers = 21
end
return reqPlayers
end
function StartElement(vcount,pcount)
vcount = 0
pcount = ReqPlayers()
triggerClientEvent("UpdateCount", getRootElement(),vcount,pcount)
triggerClientEvent("onGMStart", getRootElement())
end
Also what I noticed is that when I play a DD map the ghostmode text isn't there, yet every time in the Chat it says "Voting for ghostmode passed!"
Basically what I'm asking is if either this problem is harmless or if it's a bug and a way to fix it. If you can't help me for any reason I understand. Thanks in advance guys.