Jump to content

server side event


Gallagher

Recommended Posts

I have this client-side script.

I want to put a function or server-side event to qo script only works if the file server side "server.lua"

----Client -----

function createText1 ( ) 
 clip = getPedAmmoInClip ( getLocalPlayer() ) 
    arma = getPedWeapon( getLocalPlayer() ) 
   dxDrawText(""..clip.." | "..bala,screenWidth*0.248, screenHeight*0.955, screenWidth*0.0, screenHeight*0.0, tocolor(230, 252, 250, 255), 0.45, "bankgothic", "left", "top", false, false, false, false, false)  
      if ( arma==34 ) then  dxDrawText(" DMR ",screenWidth*0.77, screenHeight*0.02012, screenWidth*0.0, screenHeight*0.0, tocolor(50, 200, 31, 255), 1, "bankgothic", "left", "top", false, false, false, false, false) 
      elseif  ( arma==31 ) then  
      dxDrawText(" M4A1 ",screenWidth*0.77, screenHeight*0.02012, screenWidth*0.0, screenHeight*0.0, tocolor(50, 200, 31, 255), 1, "bankgothic", "left", "top", false, false, false, false, false) 
       elseif  ( arma==28 ) then  dxDrawText(" PWD ",screenWidth*0.80, screenHeight*0.020, screenWidth*0.0, screenHeight*0.0, tocolor(50, 50, 31, 205), 1.05, "bankgothic", "left", "top", false, false, false, false, false) 
      dxDrawText(" PWD ",screenWidth*0.8015, screenHeight*0.02012, screenWidth*0.0, screenHeight*0.0, tocolor(50, 200, 31, 255), 1, "bankgothic", "left", "top", false, false, false, false, false) 
       elseif  ( arma==33 ) then  dxDrawText(" winchester ",screenWidth*0.1, screenHeight*0.6, screenWidth*0.0, screenHeight*0.0, tocolor(203, 112, 31, 255), 1, "bankgothic", "left", "top", false, false, false, false, false) 
 end 
end 
function HandleTheRendering11 ( ) 
    addEventHandler ( "onClientRender", root, createText1 )  
end  
addEventHandler ( "onClientResourceStart", resourceRoot, HandleTheRendering11 ) 

Link to comment
  • MTA Team

Try this:

Client:

  
function createText1 ( ) 
 clip = getPedAmmoInClip ( getLocalPlayer() ) 
    arma = getPedWeapon( getLocalPlayer() ) 
   dxDrawText(""..clip.." | "..bala,screenWidth*0.248, screenHeight*0.955, screenWidth*0.0, screenHeight*0.0, tocolor(230, 252, 250, 255), 0.45, "bankgothic", "left", "top", false, false, false, false, false) 
      if ( arma==34 ) then  dxDrawText(" DMR ",screenWidth*0.77, screenHeight*0.02012, screenWidth*0.0, screenHeight*0.0, tocolor(50, 200, 31, 255), 1, "bankgothic", "left", "top", false, false, false, false, false) 
      elseif  ( arma==31 ) then 
      dxDrawText(" M4A1 ",screenWidth*0.77, screenHeight*0.02012, screenWidth*0.0, screenHeight*0.0, tocolor(50, 200, 31, 255), 1, "bankgothic", "left", "top", false, false, false, false, false) 
       elseif  ( arma==28 ) then  dxDrawText(" PWD ",screenWidth*0.80, screenHeight*0.020, screenWidth*0.0, screenHeight*0.0, tocolor(50, 50, 31, 205), 1.05, "bankgothic", "left", "top", false, false, false, false, false) 
      dxDrawText(" PWD ",screenWidth*0.8015, screenHeight*0.02012, screenWidth*0.0, screenHeight*0.0, tocolor(50, 200, 31, 255), 1, "bankgothic", "left", "top", false, false, false, false, false) 
       elseif  ( arma==33 ) then  dxDrawText(" winchester ",screenWidth*0.1, screenHeight*0.6, screenWidth*0.0, screenHeight*0.0, tocolor(203, 112, 31, 255), 1, "bankgothic", "left", "top", false, false, false, false, false) 
 end 
end 
function HandleTheRendering11 ( ) 
triggerServerEvent ( "abcdefghijklmnopqrstuvwxyz", localPlayer)  
end 
addEventHandler ( "onClientResourceStart", resourceRoot, HandleTheRendering11 ) 
addEvent("yes",true) 
function yes(thecode) 
if thecode == "magicbeans" then 
addEventHandler ( "onClientRender", root, createText1 ) 
end 
end 
addEventHandler("yes",root,yes) 

Server:

  
function yeah () 
triggerClientEvent(source,"yes",source,"magicbeans") 
end 
addEvent("abcdefghijklmnopqrstuvwxyz",true) 
addEventHandler("abcdefghijklmnopqrstuvwxyz",root,yeah) 

PD: I'm from my cel, don't know if everything is perfect.

Edited by Guest
Link to comment
That's not a really secure way to do it, since they can also add the server side event to do whatever it has to do.

but if cliente.lua is compiled has no way of knowing what the event

It does, they execute the script and the debug script will output that it triggered X event and is not added server side.

Link to comment

You can also set element data at server side when the player join and check the element data client side.

========================================================================

.:CiBeR:. you forget the sendTo argument.

triggerClientEvent("yes",source,"magicbeans") 

Should be:

triggerClientEvent(source,"yes",source,"magicbeans") 

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