Jump to content

server side event


Gallagher

Recommended Posts

Posted

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 ) 

Posted
I don't understand what do you mean, please explain yourself.

I want the client script to work if I have the server side also.

because as my client-side script is a thief can get into my server and steal it even if it is compiled

Posted
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

  • MTA Team
Posted

Then just trigger the event client side and check if it was succesfull, if it's not, then end the function there.

  • MTA Team
Posted (edited)

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

Posted

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") 

Posted
That's true, but you can add a secret code, then they are fried.

You can still see function names and strings in compiled Lua code.

Posted
That's true, but you can add a secret code, then they are fried.

You can still see function names and strings in compiled Lua code.

You can't with encrypt, or there is a way i don't know?

Posted

Compiled* (because encryption is not compilation, unless you are talking about the encryption method that MTA recently implemented) Lua code, yes, it's as simple as opening the file with any text editor.

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