Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Help w/ Lotto Ticket (https://forums.graalonline.com/forums/showthread.php?t=47245)

SilentSkripter1988 08-18-2003 12:16 AM

Help w/ Lotto Ticket
 
Ok my problem is that whenever I change the lotto numbers by random or by Change Numbers it changes everyone lotto numbers, I cant think of any way to fix it. I know its doing it because all the tickets read out of this.lottoa, b, and c. But I dont know any other way to do it.

// NPC made by Silent Skripter *Scripting*
if (created) {
this.lottoa = 0;
this.lottob = 0;
this.lottoc = 0;
}
if (playerchats && strequals(#c, Random Lotto Numbers)){
this.lottoa = int(random(0, 10));
this.lottob = int(random(0, 10));
this.lottoc = int(random(0, 10));
setcharprop #c, Current lotto tickets numbers: #v(this.lottoa), #v(this.lottob), #v(this.lottoc);
}
if (playerchats && strcontains(#c, Change Numbers)){
tokenize #c;
this.lottoa = strtofloat(#t(2));
this.lottob = strtofloat(#t(3));
this.lottoc = strtofloat(#t(4));
setcharprop #c, Current lotto tickets numbers: #v(this.lottoa), #v(this.lottob), #v(this.lottoc);
}
if (playerchats && strequals(#c, take ticket)) {
toweapons Lotto Ticket;
setplayerprop #c, Took 1 Lotto Ticket;
}

if (weaponfired) {
setplayerprop #c,Your numbers are #v(this.lottoa), #v(this.lottob), #v(this.lottoc);
}

Neoreno 08-18-2003 12:53 AM

Sir...you use toweapons. Bad boy, very bad boy.

But anyway, try using client.strings instead of this.variables...it may work. Maybe a for loop too with a with in it.

SilentSkripter1988 08-18-2003 12:54 AM

Whats wrong with toweapons? What do you use instead? And im not quite sure on how to use strings. Could you please post an example? Thanks for the help.

Neoreno 08-18-2003 12:55 AM

If it's online. It's best to use addweapon. And have the weapon stored in the database. And I'm too lazy/tired to post an example at the minute.

CheeToS2 08-18-2003 01:05 AM

it doesnt seem to be for a server (unless its for classic)
if it is for a server, put //#CLIENTSIDE above if (weaponfired) and use addweapons like he said, instead of toweapons.

as for it changing everyones numbers, .. thats because your commands are telling it to change everyones numbers, not a specific one :P

there are many ways to fix it..
one, you could make a command for each lotto ticket, or you could make it so the command is "change lotto a/b/c #"
then use something like:

tokenize #c;
this.lotto#t(2) = strtofloat(#t(3));

SilentSkripter1988 08-18-2003 01:10 AM

Sorry, I didn't understand the last part of your post very well, first part why put clientside with a comment thingie next to it? I want to be able to make a new ticket without it changing everyone elses tickets to the chosen number.

Neoreno 08-18-2003 01:11 AM

CheeTos, if it is changing everyone's variables, therefore it must be for some server. Not for Classic though.

CheeToS2 08-18-2003 01:13 AM

Quote:

Originally posted by Neoreno
CheeTos, if it is changing everyone's variables, therefore it must be for some server. Not for Classic though.
not necessarily, hes using this.vars and a weapon.. he could just be learning thingys

SilentSkripter1988 08-18-2003 01:16 AM

im going to change this to level or server, im just using this to test it out, but i know that it changes mine everytime I change it in singleplayer testing out the level.

osrs 08-18-2003 02:12 AM

By the way,read KSI-GS (Coding Standards).

SilentSkripter1988 08-18-2003 05:58 AM

Im still no closer to knowing how to use a client.string or why I should use a for loop in this script.

TribulationStaff 08-18-2003 06:07 AM

Now, perhaps you will take my advice and study the Newbie Scripter's Bible.
http://newbiescriptersbible.freewebspace.com/

wonderboysp2p 08-18-2003 06:32 AM

yes i think before you try to make this you should glance over commands.rtf and the nub scripting bible...

SilentSkripter1988 08-18-2003 06:52 AM

WOOHOOO I GOT IT WORKING! Whoever suggested using client.strings helped me! I figured out how to use em and it works! Now I can make lots of money on the server its goin on! Wooohoo, pm me maybe ill give u some of the cash i make.

Neoreno 08-18-2003 01:45 PM

Er, that wont be necessary.

SilentSkripter1988 08-18-2003 05:42 PM

Will the client.string be saved to the character after they log off ?

SaijinGohan 08-18-2003 05:47 PM

yes client.strings are saved

SilentSkripter1988 08-18-2003 06:11 PM

Next up multiple tickets w/ using the arrow keys to select.

Alexander 08-18-2003 07:56 PM

string array?

SilentSkripter1988 08-18-2003 10:20 PM

Yup, string array.


All times are GMT +2. The time now is 04:47 PM.

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