![]() |
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!". |
| All times are GMT +2. The time now is 02:05 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.