Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Clientside vs Serverside confusion (https://forums.graalonline.com/forums/showthread.php?t=134269629)

i8bit 10-18-2014 01:07 AM

Clientside vs Serverside confusion
 
So I always wondered something.

Let's say, you have a weapon in a player that does this.
PHP Code:

//#CLIENTSIDE
function onCreated(){
 
onTimeOut();
}

function 
onTimeOut(){
 
setTimer(0.1);
 
player.+= 1;


The player will just keep moving right. And all other players can see that movement being done also.


Now lets apply the same thing to a npc..
PHP Code:

function onCreated(){
 
onTimeOut();
}

function 
onTimeOut(){
 
setTimer(0.1);
 
this.+= 1;


The NPC keeps moving to the right. Everyone can see it. Great.
But why can't the NPC be clientside also?
Does client and serverside work different between players and NPCs?


For example, if I have this on a NPC...
PHP Code:

//#CLIENTSIDE
function onPlayerTouchsMe(){
 
this.chat "Touch";


Why can't everyone in the area see the change in function of the same NPC. Is there a way to do this all in clientside? (Showing same NPC movement for all players in real-time)

scriptless 10-18-2014 04:35 AM

Okay, to help you out here.

Not all player variables can be edited client side. Player's x and y can. Player's chat also can. But things like hearts, ap, and mp cannot.

With NPC's when you are doing client side it will only show for the client, and server side shows for everyone. There are some exceptions. When you place bomb explosions for example, or use an on exploded event. These will show for all players. It can be tricky to exactly pinpoint what will, and what will not show for one player, or all others. It's best to experiment.

Elk 10-18-2014 06:32 AM

PHP Code:

//#CLIENTSIDE
function onCreated(){ 
 
setTimer(0.1); 


function 
onTimeOut(){ 
 
setTimer(0.1); 
 
this.+= 1


should work, I've done a lot of clientside interactions like this for my tutorial areas

callimuc 10-18-2014 01:35 PM

Some flags are synchronized between clientside, besides the chat, x/y theres also tge players attributes (player.attr[#]) which are synchronized. Not all flags are and you cant specify on your own wether a flag should be synchronized or not, for that purpose you would use player.client.flag (watch out: player.client.flag not player.clientr.flag)

MysticalDragon 10-22-2014 06:23 PM

Quote:

Originally Posted by i8bit (Post 1732082)
So I always wondered something.

Let's say, you have a weapon in a player that does this.
PHP Code:

//#CLIENTSIDE
function onCreated(){
 
onTimeOut();
}

function 
onTimeOut(){
 
setTimer(0.1);
 
player.+= 1;


The player will just keep moving right. And all other players can see that movement being done also.


Now lets apply the same thing to a npc..
PHP Code:

function onCreated(){
 
onTimeOut();
}

function 
onTimeOut(){
 
setTimer(0.1);
 
this.+= 1;


The NPC keeps moving to the right. Everyone can see it. Great.
But why can't the NPC be clientside also?
Does client and serverside work different between players and NPCs?


For example, if I have this on a NPC...
PHP Code:

//#CLIENTSIDE
function onPlayerTouchsMe(){
 
this.chat "Touch";


Why can't everyone in the area see the change in function of the same NPC. Is there a way to do this all in clientside? (Showing same NPC movement for all players in real-time)


I feel like no one here really anwsered your question. The difference between clientside and serverside is that when something happens on client It HAPPENS for you since its on your client. So if your changing a npc looks or lets say its chat under //#CLIENTSIDE, thats only happening for you. However if you removed the clientside portion, the changes would be done on serverside that all players are synced to, all players would see the changes.

when you do playertouchsme on clientside its only changing the clientside coords thats within the playerscope thats touching it. However if you did it on serverside its still within the playerscope but your changing the server coords that all players are synced to.

i8bit 10-22-2014 07:27 PM

Quote:

Originally Posted by MysticalDragon (Post 1732237)
I feel like no one here really anwsered your question. The difference between clientside and serverside is that when something happens on client It HAPPENS for you since its on your client. So if your changing a npc looks or lets say its chat under //#CLIENTSIDE, thats only happening for you. However if you removed the clientside portion, the changes would be done on serverside that all players are synced to, all players would see the changes.

when you do playertouchsme on clientside its only changing the clientside coords thats within the playerscope thats touching it. However if you did it on serverside its still within the playerscope but your changing the server coords that all players are synced to.


That actually really helps. Thank you. But here's a scenario

Let's say the player does this:
PHP Code:

//#CLIENTSIDE
//whatever function
player.+= 2

Obviously you are going to see it because it is on your client. But why can other players see it because it's not serverside?

fowlplay4 10-22-2014 11:03 PM

Quote:

Originally Posted by i8bit (Post 1732242)
That actually really helps. Thank you. But here's a scenario

Let's say the player does this:
PHP Code:

//#CLIENTSIDE
//whatever function
player.+= 2

Obviously you are going to see it because it is on your client. But why can other players see it because it's not serverside?

cause player.x/y is one of the many variables that is synced back to the server.

Elk 10-23-2014 11:12 AM

you can however hide your player, and have an artificial npc take those action you want him to do clientside :p


All times are GMT +2. The time now is 03:44 AM.

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