Jump to content

outputChatBox for only one player


Memory

Recommended Posts

Hi,

how can make function outputChatBox of this code for only one player? Now, message repeat many times.

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.."'") 
triggerClientEvent("onGMUpdate",getRootElement())    
else 
outputChatBox("You have already voted for Ghostmode.",keyPresser,255,0,0) 
end 
end 
  
function success() 
local players = getElementsByType("player") 
    for theKey,thePlayer in ipairs(players) do 
    setElementData( thePlayer, "overrideCollide.uniqueblah", 0, false ) 
    outputChatBox("#B05555[Vote]#98FB98Ghostmode activated",root,255,255,255, true) 
    end 
end 
addEvent("onVoteSuccess",true) 
addEventHandler("onVoteSuccess",getRootElement(),success) 
  
function failed() 
 for k,v in ipairs(getElementsByType("player")) do 
    outputChatBox("#B05555[Vote]#FF6A6AGhostmode deactivated",root,255,255,255, true) 
end 
end 
  
addEvent("onVoteFail",true) 
addEventHandler("onVoteFail",getRootElement(),failed) 

Link to comment
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.."'") 
triggerClientEvent("onGMUpdate",getRootElement())    
else 
outputChatBox("You have already voted for Ghostmode.",keyPresser,255,0,0) 
end 
end 
  
function success() 
local players = getElementsByType("player") 
    for theKey,thePlayer in ipairs(players) do 
    setElementData( thePlayer, "overrideCollide.uniqueblah", 0, false ) 
    outputChatBox("#B05555[Vote]#98FB98Ghostmode activated",thePlayer,255,255,255, true) 
    end 
end 
addEvent("onVoteSuccess",true) 
addEventHandler("onVoteSuccess",getRootElement(),success) 
  
function failed() 
 for k,v in ipairs(getElementsByType("player")) do 
    outputChatBox("#B05555[Vote]#FF6A6AGhostmode deactivated",v,255,255,255, true) 
end 
end 
  
addEvent("onVoteFail",true) 
addEventHandler("onVoteFail",getRootElement(),failed) 

Link to comment
Thanks, but code doesn't work, message repeat
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.."'") 
triggerClientEvent("onGMUpdate",getRootElement())   
else 
outputChatBox("You have already voted for Ghostmode.",keyPresser,255,0,0) 
end 
end 
  
function success() 
    for theKey,thePlayer in ipairs(getElementsByType("player")) do 
        setElementData(thePlayer, "overrideCollide.uniqueblah", 0, false) 
        outputChatBox("#B05555[Vote]#98FB98Ghostmode activated",thePlayer,255,255,255, true) 
    end 
end 
addEvent("onVoteSuccess",true) 
addEventHandler("onVoteSuccess",getRootElement(),success) 
  
function failed() 
     outputChatBox("#B05555[Vote]#FF6A6AGhostmode deactivated",root,255,255,255, true) 
end 
addEvent("onVoteFail",true) 
addEventHandler("onVoteFail",getRootElement(),failed) 

Make sure you have copy the correct code.

Post the client side and tell me which message is repeated.

Link to comment

Full code

client

function GMStart() 
addEventHandler("onClientRender",getRootElement(),GmDefaultText) 
end 
addEvent("onGMStart",true) 
addEventHandler("onGMStart",getRootElement(),GMStart) 
function GMStop() 
removeEventHandler("onClientRender",getRootElement(),GmDefaultText) 
removeEventHandler("onClientRender",getRootElement(),VoteNumber) 
if votecount >= reqPlayers then 
triggerServerEvent("onVoteSuccess",getRootElement()) 
else 
triggerServerEvent("onVoteFail",getRootElement()) 
end 
end 
addEvent("onGMStop",true) 
addEventHandler("onGMStop",getRootElement(),GMStop) 
  
local width, height = guiGetScreenSize() 
function GmDefaultText() 
dxDrawText("Press G to vote for Ghostmode",(3/1440)*width,(570/850)*width,(1439/1440)*width,(672/850)*width, tocolor(255,255,255,255), 0.9,"bankgothic","center", "center", false, false, true) 
end 
  
function GMStart2(pcount,vcount) 
addEventHandler("onClientRender",getRootElement(),VoteNumber) 
    votecount = vcount 
     
    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 
end 
addEvent("onGMStart2",true) 
addEventHandler("onGMStart2",getRootElement(),GMStart2) 
  
function GMUpdate(vocount) 
removeEventHandler("onClientRender",getRootElement(),VoteNumber) 
votecount = votecount + 1 
addEventHandler("onClientRender",getRootElement(),VoteNumber) 
end 
  
addEvent("onGMUpdate",true) 
addEventHandler("onGMUpdate",getRootElement(),GMUpdate) 
  
function VoteNumber() 
dxDrawText(votecount.."/"..reqPlayers.." votes recieved",0,(645/890)*width,(1439/1440)*width,(701/890)*width,tocolor(0,255,0,255),0.7,"bankgothic","center","center",false,false,false) 
end      
  
function resWarning() 
if (width < 1280) and (height < 720) then 
outputChatBox("You are running on low resolutions, some elements will not appear correctly![Minimum: 1280 x 720]",255,0,0) 
end 
end 
addEventHandler("onClientPlayerJoin",getRootElement(),resWarning) 

server

  
*Created By MAR 2010 
addEvent("onMapStarting") 
  
function onResourceStart() 
executeSQLCreateTable("GmBlockList", "serial STRING") 
end 
  
function KeyBind(pcount,vcount) -- bind the key for all players. 
local resourceName = getMapName() 
if string.find(resourceName, "[DD]", 1, true) or string.find(resourceName, "DD", 1, true) then 
elseif string.find(resourceName, "[FUN]", 1, true) or string.find(resourceName, "Fun", 1, true) then 
else 
local players = getElementsByType("player") 
local pcount = getPlayerCount() 
executeSQLQuery("DELETE FROM GmBlockList") 
vcount = 0 
for k,v in ipairs (players) do  
bindKey(v,"g","down",addVote) 
setElementData( v, "overrideCollide.uniqueblah", nil, false ) 
end 
triggerClientEvent(getRootElement(),"onGMStart", getRootElement())   
triggerClientEvent(getRootElement(),"onGMStart2", getRootElement(),pcount,vcount)    
end 
end 
addEventHandler("onMapStarting",getRootElement(),KeyBind) 
  
function KeyUnBind(newStateName,oldStateName) -- unbind the key for all players when the countdown finishes. 
    if newStateName == "Running" then 
    local players = getElementsByType("player") 
    triggerClientEvent(getRootElement(),"onGMStop", getRootElement())    
        for k,v in ipairs (players) do  
        unbindKey(v,"g","down",addVote) 
        end 
    executeSQLQuery("DELETE FROM GmBlockList") 
    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.."'") 
triggerClientEvent("onGMUpdate",getRootElement())    
else 
outputChatBox("You have already voted for Ghostmode.",keyPresser,255,0,0) 
end 
end 
  
function success() 
local players = getElementsByType("player") 
    for theKey,thePlayer in ipairs(players) do 
    setElementData( thePlayer, "overrideCollide.uniqueblah", 0, false ) 
    outputChatBox("#B05555[Vote]#98FB98Ghostmode activated",thePlayer,255,255,255, true) 
    end 
end 
addEvent("onVoteSuccess",true) 
addEventHandler("onVoteSuccess",getRootElement(),success) 
  
function failed() 
 for k,v in ipairs(getElementsByType("player")) do 
    outputChatBox("#B05555[Vote]#FF6A6AGhostmode deactivated",v,255,255,255, true) 
end 
end 
  
addEvent("onVoteFail",true) 
addEventHandler("onVoteFail",getRootElement(),failed) 

Link to comment
function resWarning() 
if (width < 1280) and (height < 720) then 
outputChatBox("You are running on low resolutions, some elements will not appear correctly![Minimum: 1280 x 720]",255,0,0) 
end 
end 
addEventHandler("onClientPlayerJoin",getRootElement(),resWarning) 

should be:

function resWarning() 
if (width < 1280) and (height < 720) then 
outputChatBox("You are running on low resolutions, some elements will not appear correctly![Minimum: 1280 x 720]",255,0,0) 
end 
end 
addEventHandler("onClientResourceStart", resourceRoot, resWarning) 

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