Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Problem with simple script (https://forums.graalonline.com/forums/showthread.php?t=134261788)

Jiroxys7 01-20-2011 07:47 PM

Problem with simple script
 
PHP Code:

//#CLIENTSIDE
function onPlayerchats(){
  if(
player.level in serverr.socialzones){
    
client.exp += 1;
  }


the level I'm testing is in serverr.socialzones, I've tried both with and without quotes but no luck. when I try putting an else{player.chat = player.level SPC serverr.socialzones;} the results visibly match.


What's going on?

fowlplay4 01-20-2011 07:49 PM

player.level.name in serverr.socialzones

Also try..

temp.socialzones = serverr.socialzones.tokenize(",");

in case your "array" isn't properly formatted.

Jiroxys7 01-20-2011 07:58 PM

Quote:

Originally Posted by fowlplay4 (Post 1624409)
player.level.name in serverr.socialzones

Also try..

temp.socialzones = serverr.socialzones.tokenize(",");

in case your "array" isn't properly formatted.

player.level.name fixed it, thanks. I must ask of course, what did .name do exactly? returning player.level and player.level.name though chat yield visually the same thing.

Tigairius 01-20-2011 08:02 PM

Quote:

Originally Posted by Jiroxys7 (Post 1624411)
player.level.name fixed it, thanks. I must ask of course, what did .name do exactly? returning player.level and player.level.name though chat yield visually the same thing.

Player.level is an object, not a string. Thus, you must access the 'name' variable of the object by appending '.name' to the end of 'player.level'.

Jiroxys7 01-20-2011 08:05 PM

Quote:

Originally Posted by Tigairius (Post 1624412)
Player.level is an object, not a string. Thus, you must access the 'name' variable of the object by appending '.name' to the end of 'player.level'.

ah, thank you. :D

Skyld 01-20-2011 08:14 PM

Quote:

Originally Posted by Jiroxys7 (Post 1624411)
player.level.name fixed it, thanks. I must ask of course, what did .name do exactly? returning player.level and player.level.name though chat yield visually the same thing.

As a part of the dynamic typing in GScript, if you try and represent an object as a string (which would have been what you did when you set player.chat = player.level;), then it automatically is showing the object name. However, this does not happen when you are working with the object itself because there is no such type conversion taking place, therefore you need to access the name attribute manually.

AlexanderK 01-22-2011 12:07 AM

I'm new to this, but shouldn't the experience be stored in a clientr. variable so it is safe?

Fulg0reSama 01-22-2011 12:11 AM

Quote:

Originally Posted by AlexanderK (Post 1624694)
I'm new to this, but shouldn't the experience be stored in a clientr. variable so it is safe?

client would actually not be safe from trainer abusers and "hackers" I agree so.. really I'unno prolly not though.

cbk1994 01-22-2011 12:47 AM

Quote:

Originally Posted by AlexanderK (Post 1624694)
I'm new to this, but shouldn't the experience be stored in a clientr. variable so it is safe?

Yes (note that this would require triggering serverside to set it.)

fowlplay4 01-22-2011 01:08 AM

Quote:

Originally Posted by AlexanderK (Post 1624694)
I'm new to this, but shouldn't the experience be stored in a clientr. variable so it is safe?

Wordy yes.

Yes thats a perfectly fine way to do it, as long as it's being validated on the server-side.

Provided the EXP system is checking EXP on the server-side after it's added then there's no problem with trainers/CEs since they can only change the visible value to the client.

Unless they manipulate the client in such a way that it allows them to exploit a method to earn exp.


All times are GMT +2. The time now is 01:30 PM.

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