![]() |
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); } |
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. |
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.
|
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.
|
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)); |
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.
|
CheeTos, if it is changing everyone's variables, therefore it must be for some server. Not for Classic though.
|
Quote:
|
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.
|
By the way,read KSI-GS (Coding Standards).
|
Im still no closer to knowing how to use a client.string or why I should use a for loop in this script.
|
Now, perhaps you will take my advice and study the Newbie Scripter's Bible.
http://newbiescriptersbible.freewebspace.com/ |
yes i think before you try to make this you should glance over commands.rtf and the nub scripting bible...
|
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.
|
Er, that wont be necessary.
|
Will the client.string be saved to the character after they log off ?
|
yes client.strings are saved
|
Next up multiple tickets w/ using the arrow keys to select.
|
string array?
|
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.