Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Quick update level (https://forums.graalonline.com/forums/showthread.php?t=134262564)

McChucken 03-27-2011 02:17 AM

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 = "";
}

cbk1994 03-27-2011 02:22 AM

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.

McChucken 03-27-2011 02:29 AM

Not at all this is my first script so thanks for your help :)

McChucken 03-27-2011 11:39 AM

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?

Mark Sir Link 03-27-2011 11:54 AM

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

McChucken 03-27-2011 12:31 PM

Because its easier to use the command then clear the chat then u dont have to wait for it to dissapear itself


All times are GMT +2. The time now is 02:11 PM.

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