Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 10-18-2014, 01:07 AM
i8bit i8bit is offline
Registered User
Join Date: Jul 2013
Posts: 146
i8bit is an unknown quantity at this point
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)
Reply With Quote
  #2  
Old 10-18-2014, 04:35 AM
scriptless scriptless is offline
Banned
Join Date: Dec 2008
Location: N-Pulse
Posts: 1,412
scriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to beholdscriptless is a splendid one to behold
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.
Reply With Quote
  #3  
Old 10-18-2014, 06:32 AM
Elk Elk is offline
Sr Marketing Strategist
Elk's Avatar
Join Date: Nov 2005
Location: Deerland
Posts: 3,829
Elk has a brilliant futureElk has a brilliant futureElk has a brilliant futureElk has a brilliant futureElk has a brilliant futureElk has a brilliant futureElk has a brilliant future
Send a message via ICQ to Elk Send a message via AIM to Elk Send a message via MSN to Elk Send a message via Yahoo to Elk
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
__________________
iEra IGN: *Elk (Darkshire)
iCla. IGN: *Elk (Darkshire)
iZone IGN: *Elk (Darkshire)




Reply With Quote
  #4  
Old 10-18-2014, 01:35 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
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)
__________________
MEEP!
Reply With Quote
  #5  
Old 10-22-2014, 06:23 PM
MysticalDragon MysticalDragon is offline
Global Administration
MysticalDragon's Avatar
Join Date: Oct 2002
Location: Lynn Ma
Posts: 883
MysticalDragon is just really niceMysticalDragon is just really nice
Send a message via AIM to MysticalDragon Send a message via MSN to MysticalDragon
Quote:
Originally Posted by i8bit View Post
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.
__________________
~Delteria Support
~Playerworld Support
~PWA Chief
http://support.toonslab.com
[email protected]



Reply With Quote
  #6  
Old 10-22-2014, 07:27 PM
i8bit i8bit is offline
Registered User
Join Date: Jul 2013
Posts: 146
i8bit is an unknown quantity at this point
Quote:
Originally Posted by MysticalDragon View Post
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?
Reply With Quote
  #7  
Old 10-22-2014, 11:03 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by i8bit View Post
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.
__________________
Quote:
Reply With Quote
  #8  
Old 10-23-2014, 11:12 AM
Elk Elk is offline
Sr Marketing Strategist
Elk's Avatar
Join Date: Nov 2005
Location: Deerland
Posts: 3,829
Elk has a brilliant futureElk has a brilliant futureElk has a brilliant futureElk has a brilliant futureElk has a brilliant futureElk has a brilliant futureElk has a brilliant future
Send a message via ICQ to Elk Send a message via AIM to Elk Send a message via MSN to Elk Send a message via Yahoo to Elk
you can however hide your player, and have an artificial npc take those action you want him to do clientside
__________________
iEra IGN: *Elk (Darkshire)
iCla. IGN: *Elk (Darkshire)
iZone IGN: *Elk (Darkshire)




Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 11:48 AM.


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