Hello everyone!
I'm not the greatest scripter by any means (as I'm sure you'll be able to tell from my code), but, I tried to write this script yesterday (from scratch). I have a question or two about it and I'm hoping someone may be able to help me...
(This script is currently on the "onUsed" event for an object.)
1) Right now, I'm just trying to get the name of this game object to change "Jackpot: 15" and if you play again / lose then it should say "Jackpot: 30". Each time I play and lose it continuosly stays at Jackpot: 15. I'm assuming thats because each time this is "onUsed" it re-initializes the "jackpot" variable, thus resetting it. If I'm right about that, could someone maybe give me a hint on how to get around reinitializing it. Maybe constructing it somewhere else? Idk. (I know that I can put the word Jackpot on the original string name, I don't know why I didn't do it to start).
2) I dislike how "onUsed" is executed just by a single mouse click because there is a chance a character could "play" this game on accident before reading the description / rules, etc. (How could I MAKE the player have to use the mouse menu to "play" this game). Would "onOpen" work better for some reason? What about, "onDisturbed"? I'm not exactly familiar with what dictates an onDisturbed event. None-the-less, I'm kind of stumped here.
3)
#include "nw_i0_plot"
void SetNewName(int JP)
{
string originalName, strJackpot;
object theGame = GetObjectByTag("gettingbootymachine"); //our machine
SetName(theGame, ""); //clears the name
originalName = GetName(theGame, FALSE); //get the game name with jackpot info
originalName += " Jackpot: ";
strJackpot = IntToString( JP );
SetName(theGame, originalName + " " + strJackpot);
}
void main()
{
int jackpot;
int oPCtotalgold;
int gameCost = 15;
string strJPwinnings;
object oPC = GetLastUsedBy(); //our player
oPCtotalgold = GetGold(oPC);
if(oPCtotalgold <= 14) //check to see if you have enough gold to play
{
SendMessageToPC( oPC, "You do not have enough gold to use this machine!" );
}
else //lets play
{
TakeGold(gameCost, oPC, TRUE);
int jackpotRoll;
int winningNumber = 468;
jackpotRoll = Random(1000);
if(jackpotRoll == 468) //WINNING NUMBER IS 468
{
strJPwinnings = IntToString( jackpot );
RewardGP(jackpot, oPC, FALSE); //gives jackpot to oPC only (not party)
SendMessageToPC(oPC, "Congratulations! You just won the jackpot of " + " " + strJPwinnings + " Spend it wisely!");
//SendMessageToAllDMs( ); Notify DMs of jackpot winner / payout TO BE DONE AT A LATER DATE
jackpot = 0;
SetNewName(jackpot);
}
else //LOSING
{
SendMessageToPC(oPC, "Sorry, you lose.");
jackpot += gameCost; //add oPC gold to the pot
strJPwinnings = IntToString( jackpot );
SetNewName(jackpot);
SendMessageToPC(oPC, "Jackpot is now " + strJPwinnings);
}
}
}
I mean, I realize I'm amateurish but I kind of have a decent idea on how its supposed to work. If someone could maybe just help me understand some of these things a little bit better I'd much appreciate it!