Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-08-2005, 06:59 PM
prozac424242 prozac424242 is offline
Registered User
prozac424242's Avatar
Join Date: May 2001
Location: Gone crazy: back soon
Posts: 356
prozac424242 is on a distinguished road
Send a message via ICQ to prozac424242 Send a message via AIM to prozac424242
Placing string values in your text

One thing in gs2 that I have been trying off and on how to figure out is how to put variables in strings. After seeing some random examples and taking a closer look at the gscript wiki page that I have read many times, it finally occured to me. And since for me, the solution was so elusive, I will post it here so others can see how this rather simple thing is done.

The @ symbol is what combines strings, or strings and variables, in gs2.
If you want a gui box to show the player's name at the end, you could have the text line of the GuiTextCtrl box be

PHP Code:
text "Welcome to some server that is crappy but I can't tell beacsue I am a noob with money who rented a spot and threw stuff together, "@player.nick
So: You define a string by putting it in quotes "like this"
and the player.nick is a variable whose type is a string, so it does not need quotes. The @ does not read the contents of player.nick, it simply sticks the two together.

But what if you want to put more text after the player's name?
You use another @
PHP Code:
text "Welcome to some server that is crappy but I can't tell becasue I am a noob with money who rented a spot and threw stuff together, "@player.nick@" , so have fun trying to figure out my obtuse customized player movement and swords that hit off target and graphics ripped from emulators, you know the drill.  Enjoy it while your gold account lasts casue i r b 1337 baby!"
If, instead of the player's name, you want to put in a player variable or a server string, #s(client.whateveryoucalledthestring) and #s(serverr.thestringnameyougavefortheserverstring) still works.

Also, if you have a Gui box whose text you want updated, having any kind of setTimer(number) will casue the text to flash. .05 time casues the text to not show at all, if read from a server string, if I remember correctly the server's fastest response time is .1, so in the timeout, do a check that grabs the string value to a variable, sleep for .1, and check the variable against the current string value. If the values differ, then update the text attribute of whatever you called the box. The text attribute for GuiTextCtrl ("My_Text") would be My_Text.text and you can set it equal to whatever you like in a separate part of the npc.

I hope this helps someone, and please correct me where I am wrong. But what I did here (with different text of course) works on my server.
__________________

Useful links:
Graal Stats
Client Script Functions-GS1 to GS2
Serverside Script Functions-Gscript page
Particle Engine-Player Attributes
Server Options-Admin rights-Gmaps
Quote:
Originally Posted by Admins
Thanks for developing and improving playerworlds and such
Reply With Quote
 


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:57 AM.


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