Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-27-2011, 02:17 AM
McChucken McChucken is offline
Sound Artist
McChucken's Avatar
Join Date: Mar 2011
Posts: 42
McChucken has a little shameless behaviour in the past
Quick update level

This is for you if you are sick of typing "update level" every time you need the level updated. Simply press 1 and it will update the level for you. Add this as a WNPC and add it to yourself!

Quote:
//Scripted by McChucken
//#CLIENTSIDE
function onKeyPressed(num1, code, num2)
{
if (code == "1") {
player.chat = "update level";
}
sleep 0.1;
player.chat = "";
}
__________________
Also know as Emera
Reply With Quote
  #2  
Old 03-27-2011, 02:22 AM
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
Please indent your code if you're going to release it, and use PHP tags instead of QUOTE tags.

PHP Code:
//Scripted by McChucken
//#CLIENTSIDE
function onKeyPressed(num1codenum2)
{
  if (
code == "1") {
    
player.chat "update level";
  }
  
sleep 0.1;
  
player.chat "";

In addition, there are several errors with it. Since the sleep and the line that resets the player's chat aren't in the if block, they'll happen any time you press a key.

I've corrected the code and left comments:
PHP Code:
//Scripted by McChucken
//#CLIENTSIDE
function onKeyPressed(codekeyscancode) { // code is the first parameter, not the second
  
if (key == "1") {
    
player.chat "update level";
    
sleep(0.1); // use parentheses for parameters, you had GS1 before
    
player.chat "";
  }

Nice attempt, though. Trying is the best way to learn. Sorry if I come off as being an ass, I'm just trying to make sure you understand the mistakes so you'll become a better scripter.
__________________
Reply With Quote
  #3  
Old 03-27-2011, 02:29 AM
McChucken McChucken is offline
Sound Artist
McChucken's Avatar
Join Date: Mar 2011
Posts: 42
McChucken has a little shameless behaviour in the past
Not at all this is my first script so thanks for your help
__________________
Also know as Emera
Reply With Quote
  #4  
Old 03-27-2011, 11:39 AM
McChucken McChucken is offline
Sound Artist
McChucken's Avatar
Join Date: Mar 2011
Posts: 42
McChucken has a little shameless behaviour in the past
Hey cbk, i know you might not have the time, but can you please be like my scripting tutor, so to speak, for a while so i can grasp GS2?
__________________
Also know as Emera
Reply With Quote
  #5  
Old 03-27-2011, 11:54 AM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
I'm not sure why you'd need to clear the chat by script unless you were planning on spamming this anyway

You'd probably be better off cutting that bit out of the script
Reply With Quote
  #6  
Old 03-27-2011, 12:31 PM
McChucken McChucken is offline
Sound Artist
McChucken's Avatar
Join Date: Mar 2011
Posts: 42
McChucken has a little shameless behaviour in the past
Because its easier to use the command then clear the chat then u dont have to wait for it to dissapear itself
__________________
Also know as Emera
Reply With Quote
Reply


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 10:59 AM.


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