What am I doing wrong? (Goal: purchase one raffle ticket if I log in as my main)

Lxndr

Member
Goal: purchase one raffle ticket if I log in as my main ("Lxndr")

Code:

if (my_name() == "Lxndr") {
cli_execute("raffle 1");

}

Result: Nothing. No error messages, no nothing.
 

lostcalpolydude

Developer
Staff member
> ashq print( "help" == "HElp" )

false

> ashq print( "help" == "help" )

true

That was changed fairly recently.

> ashq if ( my_name() == "bmaher" ) { cli_execute( "raffle 1" ); }

Visiting the Raffle House...
You acquire raffle ticket
Requests complete.

So the command still works, and still gives output. I don't see any way to not get an error message of some kind (or success message) from that command.
 

Theraze

Active member
Two things. One, the top of that wiki page says that my_name returns in all lowercase. You aren't checking for your name in lowercase. Two, string comparisons were made case sensitive a while ago and the lower part of the wiki page is out of date.
 

Lxndr

Member
Okay, I tried lowercase, it's working.
Any ideas how I can make it trigger only if I have no raffle tickets?
 

Darzil

Developer
Two things. One, the top of that wiki page says that my_name returns in all lowercase. You aren't checking for your name in lowercase. Two, string comparisons were made case sensitive a while ago and the lower part of the wiki page is out of date.
So that's why my character specific settings stopped working months ago! Thanks !
 

Bale

Minion
Okay, I tried lowercase, it's working.
Any ideas how I can make it trigger only if I have no raffle tickets?


Try this: (modified from my loginScript)

Code:
	// Buy raffle tickets every day
	if(my_name().to_lower_case() == "lxndr" && get_property("_loginRaffle") == "") {
		if(visit_url("main.php").contains_text("map7beach.gif") && my_path() != "Zombie Slayer")
			cli_execute("raffle 1 " + (can_interact() && my_meat() > 1000? "inventory": "storage"));
		set_property("_loginRaffle", "done");
	}

Although, come to think of it, I could have just checked for available_amount() of raffle tickets. Not sure why I didn't do that since they are actual items...
 
Last edited:

Bale

Minion
Okay. Here's something better:

Code:
	int ticket_qty = 1;
	if(available_amount($item[raffle ticket]) < ticket_qty && my_name().to_lower_case() == "lxndr" && visit_url("main.php").contains_text("map7beach.gif") && my_path() != "Zombie Slayer")
		cli_execute("raffle " + ticket_qty + (can_interact() && my_meat() > ticket_qty * 10000? " inventory": " storage"));
 
Last edited:

Bale

Minion
I'm checking your inventory instead of setting a daily preference. That means if you bought a raffle ticket outside of mafia it will still know that you did this and it will act properly. (Daily raffle tickets are kept as items in inventory until rollover when they disappear.)

Also, I set the number of raffle tickets to buy with a variable, so you can change the daily number of tickets by editing a single number at the top.
 
Top