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 08-13-2011, 05:46 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Custom Name System

vHere is what have been able to come up with, but im still wondering, is there any way to check if the player is staff and if so make their name gold? iv managed to achieve this clientside but not serverside, meaning it only displays as gold to your self.

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
onTimeOut();
}

function 
onTimeOut() {
  
hideimg(201 a);
  
hideimg(202 a);
  for (
0playerscounta++) {
    
showtext(201 aplayers[a].1.5players[a].3.2"Arial Bold""c", @players[a].nick);
    
changeimgcolors(201 a1111);
    
changeimgvis(201 a1);
    
changeimgzoom(201 a1);
    
showtext(202 aplayers[a].1.5players[a].4.5"Arial Bold""c", @players[a].hearts@"/"@players[a].maxhp);
    
changeimgcolors(202 a10.10.11);
    
changeimgvis(202 a1);
    
changeimgzoom(202 a0.8);
  }
  
setTimer(0.05);

__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion

Last edited by Gunderak; 08-13-2011 at 07:11 PM..
Reply With Quote
  #2  
Old 08-13-2011, 06:55 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
Again, you need to work on your styling. In addition, the smallest timeout possible is 0.05 seconds, not 0.001 seconds.

The best way is probably to store some value in a player attribute (the attr array) so that you can check it clientside on other clients.
__________________
Reply With Quote
  #3  
Old 08-13-2011, 07:10 PM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Iv changed to 0.05 il remember that for next time and yeah sorry about my styling. i fixed that too. i keep forgetting that it makes it hard to read for others :3
as for storing it in attributes.
not to be too suddle, but how the hell would i do that? would you be ever so kind to link me or show an example?
thanks.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #4  
Old 08-13-2011, 09:31 PM
ffcmike ffcmike is offline
Banned
Join Date: Jul 2004
Location: London
Posts: 2,029
ffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond reputeffcmike has a reputation beyond repute
Send a message via AIM to ffcmike Send a message via MSN to ffcmike
Quote:
Originally Posted by Gunderak View Post
vHere is what have been able to come up with, but im still wondering, is there any way to check if the player is staff and if so make their name gold? iv managed to achieve this clientside but not serverside, meaning it only displays as gold to your self.

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
onTimeOut();
}

function 
onTimeOut() {
  
hideimg(201 a);
  
hideimg(202 a);
  for (
0playerscounta++) {
    
showtext(201 aplayers[a].1.5players[a].3.2"Arial Bold""c", @players[a].nick);
    
changeimgcolors(201 a1111);
    
changeimgvis(201 a1);
    
changeimgzoom(201 a1);
    
showtext(202 aplayers[a].1.5players[a].4.5"Arial Bold""c", @players[a].hearts@"/"@players[a].maxhp);
    
changeimgcolors(202 a10.10.11);
    
changeimgvis(202 a1);
    
changeimgzoom(202 a0.8);
  }
  
setTimer(0.05);

There's a couple of things within this script which don't really make sense, and suggest that you are still piecing things together without really understanding how they work.

First of all you do not need to use "@" to use a single variable such as how you do with "@players[a].nick", this is the type of thing you'd want to do in order to create an object from a dynamic string value, for instance:

PHP Code:
function onPlayerChats(){
  
temp.tokens player.chat.tokenize();
  
//lets say the players chat was "/dofunction heal somenoob 2"
  
if(temp.tokens[0] == "/dofunction"){
    
//temp.tokens[1] would be the function name it invokes, temp.tokens[2] + [3] would be the parameters passed
    
this.(@ temp.tokens[1])(temp.tokens[2], temp.tokens[3]);
  }
}

function 
heal(temp.pltemp.amount){
  
//stuff that heals the player supplied by the first parameter by the amount supplied in the second parameter


The 2nd parameter also does not require the first "@", it can be "players[a].hearts @ "/" @ players[a].maxhp", for the sake of read-ability it would also be better to space those separate values out.

Something more important is that when using indexes of 201 + a, and 202 + 1 and incrementing a by 1, the 2nd part of the loop will be over-writing one of the displays from the first part of the loop and so on.
For this you should be incrementing a by 2, this would do 201 and 202 for the first part of the loop, then 203 and 204 for the second part.

Having said that, it would be much better to simply do:

PHP Code:
for(temp.pl players){
  
this.showtext(200 this.itemp.pl.xtemp.pl.ystuff);
  
this.++;
  
this.showtext(200 this.itemp.pl.xtemp.pl.ystuff);
  
this.++;

Your hideimg functions are only hiding the first 2 display objects and would be ignoring any players beyond yourself.
If you keep track of the amount of displays created, you can do something simple such as :

PHP Code:
this.hideimgs(200200 this.i); 
Even then looping through all players and creating a new display every frame is a very inefficient method which consumes script time, I personally think it's better to just stick to default nicks unless you're knowledgeable enough to create an efficient system, such as storing the display objects and then simply modifying them in future frames.

I'm not 100% sure but I think the playerscount variable is a now deprecated relic of old GS1, you may for example have to use temp.s = players.size(); and refer to temp.s within the loop.
Reply With Quote
  #5  
Old 08-15-2011, 07:07 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
wow thats alot to chew.
yes i am still piecing together things on this script.
i would like to also learn about paramaters.
like for example if i had a triggerserver then at the end after it had the server param to trigger i did , player.whatever) iv noticed some scripts have this and then at the top it reads that param but im still confused on how that works.
thanks very much for your time and effort i really do want to learn GS2.
i think il abandon the custom name system.
what does the players[a].health does that mean all players? and why is it players and not player? that confuses me too :$
if you want to see what iv done so far have a look at dev draze.
anyway thanks for your help thor, il be sure to keep your afvice in mind
i think im trying to make things out of my abilities again :3
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #6  
Old 08-15-2011, 07:09 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
also sorry il have to rep you when i get home, my iDevice doesnt seem capable of it.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #7  
Old 08-15-2011, 12:59 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
How do you type that poorly on an iDevice? Doesn't it capitalize stuff for you...?
__________________
Reply With Quote
  #8  
Old 08-15-2011, 06:09 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
Quote:
Originally Posted by cbk1994 View Post
How do you type that poorly on an iDevice? Doesn't it capitalize stuff for you...?
Just if you have the autocorrection turned on
__________________
MEEP!
Reply With Quote
  #9  
Old 08-19-2011, 02:34 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Beaides the fact autocorrect is off, im also typing while im at work and doing other things.
So sorry youl have to excuse my poor grammar.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #10  
Old 08-19-2011, 02:54 AM
Bubble13 Bubble13 is offline
Registered User
Join Date: Sep 2010
Location: USA
Posts: 172
Bubble13 is on a distinguished road
Quote:
Originally Posted by Gunderak View Post
Beaides the fact autocorrect is off, im also typing while im at work and doing other things.
So sorry youl have to excuse my poor grammar.
Maybe you should stop what you're doing and just focus on typing. It would make it easier for everyone.
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 08:46 AM.


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