![]() |
Lottery NPC
Basically i got the idea from xXAndrewXx.
But i noticed somthing with his script. The information isn't stored properly, meaning if the npc server were restarted or someone updated the level all the data would disappear. so i set off to script it from scratch. here is my problem, i cant figure out how to make serverr.winner be the winner. here is what i would like it to do, if any player has clientr.Ticket=1 there a potential candidate for the winner flag. here is my script so far. PHP Code:
|
1. Would be best if you post the original link. Lottery System
2. Quote:
|
Mine i made as a level npc.
how would i accomplish the same thing without using a db npc do you know? thanks btw. |
I donīt think you can store stuff without using a DB. Only way would be to store the players in server flags OR to save them in a text file where you read it from.
|
I'd prefer making it databased, but nice work
|
You can use a DB to store the people who entered the lottery like this:
DB-NPC: Lottery PHP Code:
Lottery.addAccount(player.account); To check if a player is in the lottery use: if (Lottery.inLottery(player.account)) To pick a winner use: temp.winner = Lottery.pickLotteryWinner(); To clear the lottery entries: Lottery.clearAccounts(); You don't have to store any information in the player's or server flags, you can also expand upon this and add/update/store the "Jackpot" amount in it as well but I'm not going to do everything for you. |
Quote:
PHP Code:
PHP Code:
Thanks for taking the time to either style your code or run it through Jer's beautifier before posting it. |
Another thing to note is your usage of serverr variables. Judging by your script you really only need to use server (only one r) variables because you aren't accessing them on the client-side and are instead using player chat to display it.
serverr variables are stored on the server-side and synced with the client-side. server variables are just stored on the server-side. |
Thanks fowlplay for explaining it clearly how to use database npcs :D
without your help id probably be stuck for the next week :redface: and cbk1994 i copied it into the offline level editor inside a npc and clicked style. @Everyone thanks for your help :) |
I forgot to ask, when rewarding the players the jackpot would this work?
PHP Code:
thats another problem im likely to face. and thanks fowlplay server variables work for this. so serverr variables are accesible clientside? and server variables are acessible serverside? can they both be written server and clientside? thanks |
DB-NPC's script, I labeled it as such.
and no, it returns the account of the player not the object. That's when you would use findplayer. I.e: findplayer(temp.winner).rupees += jackpot; Rather than having your script award them directly, you could just have the NPC pick a winner and hand out the amount yourself. There is a way to add to people who are offline though but you should fix your scripts existing problems before you introduce more. Use my beautifier instead of the level editor, it does a lot more than indenting. Link: http://fp4.ca/gs2beautifier |
Ah ok, i think il do the awarding my self and then later if i can be bothered make it automatic, il make it send the winner to rc maybe.
also nice work with the styler, did the makers of the original one give you the source code? or is it publicly avaliable? |
Quote:
http://github.com/einars/js-beautify |
PHP Code:
|
Quote:
At the very least, post your whole script. It's very hard to help you when you don't provide any information besides "it's not working X_X!". |
no, i havnt tried debugging it. i dont know how to do tasks that advanced.
here is the db npc script PHP Code:
PHP Code:
|
Quote:
Quote:
Quote:
Perhaps try something like this to ensure that does not happen, although this does very slightly affect the odds... PHP Code:
|
Quote:
|
I've looked at his script and I don't really see anything wrong with it, and tested mine.
PHP Code:
PHP Code:
|
*facepalm*
i couldn't be more wrong. it turns out it was a coincidence. Its just when he won four times in a row and we both entered in the same order each time i got suspicious. |
May i ask how the computer is physically able to pick a random one?
does it use huge algorithms or something? |
Quote:
|
Quote:
In terms of debugging, it's not as complicated as it seems. You simply make things that aren't visible, visible. ie, in your code you have PHP Code:
PHP Code:
That's just one method of debugging, but just remember all you need to do to debug it is produce extra output that you can see, so you can watch how the code is working. |
In terms of debugging i didnt think for a second to think outside the square.
i understand what id have to do to debug things. so basically try and produce a visual output so i can physically see whats not working? |
@cbk1994 so it uses algorithms =D yay me is smrt! LIKE A BOSS!
|
Quote:
|
@jamitsu89 ah ok i get how debugging works now :D!
@everyone thanks for your help. |
@Whoever neg repped me for joking around at cbk1994 seriously skrew you.
your comment is "don't act like a child" where you are the one who is truely acting like a child. wait sorry didnt realise we couldnt have any fun on these forums. This proves furthermore you are the child. |
Quote:
|
Quote:
|
Well neg repping someone because there having a little bit of fun isn't necessary.
|
and again someone neg reps me for posting...
i cant believe some people. |
Maybe because you keep double posting for no reason and keep starting crap with people.
|
Quote:
You win a yacht! |
| All times are GMT +2. The time now is 05:10 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.