Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #16  
Old 05-25-2010, 12:57 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
They could edit the numbers with a memory editor. As a general rule of thumb when writing code, pretend that all of your clientside code can be changed by a hacker. You should always validate the data on serverside (or hide it somehow) if it's important enough that it will be changed.
__________________
Reply With Quote
  #17  
Old 05-25-2010, 05:18 PM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
Quote:
Originally Posted by Jiroxys7 View Post
I believe im fairly familiar with using the serverside <=> clientside stuff. didnt know the difference between temp.var and this.var though =3

so if i want to create an important clientr.var, i should do something like this?:

example:
<snip>

clientr.num should equal 3.

now, I'm wondering though, are people able to hack and edit this.num1 and this.num2 to change the outcome of clientr.num? or is it just harder to hack compared to client.vars?
The values of this.num1 and this.num2 are being passed as parameters, not the actual variables themselves. It would look like this:

PHP Code:
function onActionServerSide(cmdp1p2) { // you can call these whatever you want
  
if (temp.cmd == "calc_math") {
    
// p1 and p2 hold the values 1 and 2
    
    
doMakeMathVar_S(temp.p1temp.p2);
  }
}

function 
doMakeMathVar_S(num1num2){ // again, call these parameters whatever you want
   
clientr.num temp.num1 temp.num2// parameters are temp.vars -- only accessible within the function block
}

//#CLIENTSIDE

function doMakeMathVar_C() {
  
// There's really no reason to use this.vars here because you 
  // only need them  within this function block
  // for sake of learning, I'll leave it as you had it
  
  
this.num1 1;
  
this.num2 2;
  
triggerServer("weapon"this.name"calc_math"this.num1this.num2);

__________________
Reply With Quote
  #18  
Old 05-25-2010, 08:01 PM
Jiroxys7 Jiroxys7 is offline
Hazard to Graal
Jiroxys7's Avatar
Join Date: Apr 2009
Posts: 343
Jiroxys7 will become famous soon enough
Quote:
Originally Posted by salesman View Post
The values of this.num1 and this.num2 are being passed as parameters, not the actual variables themselves. It would look like this:

<snip>
For some reason, the values werent going through unless i did something like this:

PHP Code:
function onActionServerSide(cmdv1v2) {
  if (
cmd == "calc_math") {
    
doMakeMathVar_S();
  }
}

doMakeMathVar_S(){
    
clientr.num params[1] + params[2]; // <-------
}

//#CLIENTSIDE

function onTimeout() {  
  
temp.num1 1;
  
temp.num2 2;
  
triggerServer("weapon"this.name"calc_math"temp.num1temp.num2);
  
player.chat clientr.num;
}

setTimer(1); 
__________________
MY POSTS ARE PRONE TO EDITS!
Reply With Quote
  #19  
Old 05-25-2010, 08:12 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
Quote:
Originally Posted by Jiroxys7 View Post
For some reason, the values werent going through unless i did something like this:

PHP Code:
function onActionServerSide(cmdv1v2) {
  if (
cmd == "calc_math") {
    
doMakeMathVar_S();
  }
}

doMakeMathVar_S(){
    
clientr.num params[1] + params[2]; // <-------
}

//#CLIENTSIDE

function onTimeout() {  
  
temp.num1 1;
  
temp.num2 2;
  
triggerServer("weapon"this.name"calc_math"temp.num1temp.num2);
  
player.chat clientr.num;
}

setTimer(1); 
Shouldn't it be more like this
PHP Code:
function onActionServerSide(cmdv1v2) {
  if (
cmd == "calc_math") {
    
doMakeMathVar_S(v1,v2);
  }

also what's with the random setTimer(1);
Reply With Quote
  #20  
Old 05-25-2010, 08:43 PM
Jiroxys7 Jiroxys7 is offline
Hazard to Graal
Jiroxys7's Avatar
Join Date: Apr 2009
Posts: 343
Jiroxys7 will become famous soon enough
PHP Code:
function onActionServerSide(cmdv1v2) {
  if (
cmd == "calc_math") {
    
doMakeMathVar_S();
  }
}

doMakeMathVar_S(){
    
clientr.num params[1] + params[2];

seems to work the same as

PHP Code:
function onActionServerSide(cmdv1v2) {
  if (
cmd == "calc_math") {
        
clientr.num params[1] + params[2];
  }

I'm guessing because the v1 and v2 params or w/e were accessable through the entire serverside section of the script. making the doMakeMathVar_S function right there seem a bit redundant unless i can get the things to send values across eachother.

As for the timeout, when i was incorporating this into one of my other scripts and it didnt work, i played around with the example for a while to try getting it to work. i've found that looping something in player.chats is often very useful for finding where problems in scripts might be occuring. i suppose i couldve just put it in it's own timeout but since it's just an example, i looped that entire part. otherwise, if youre commenting on it being set to 1 as being random, like i said. it's an example so i just put whatever in that works.
__________________
MY POSTS ARE PRONE TO EDITS!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 02:11 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.