Using an item on somebody

amosmj

New member
If you want to use and item, like Toilet Paper on someone, how do you script that?
I thought maybe three parameters in the Use command would do it but it doesn't look like it's built to handle that.
 
This should do what you want. If you don't have as many of the item as you specified, it will use however many you have.

Code:
void main( int num , string it , string who )
{
	item it2 = to_item( it );
	string item_num = to_string( to_int( it2 ) );
	if( item_num != "2192" && item_num != "1923" && item_num != "1694" && item_num != "2019" && item_num != "3275" )
	{
		abort( "This item cannot be used on other players" );
	}
	
	if( item_amount( it2 ) < num )
	{
		print( "You tried to use " + num + " " + it2 + " but you only have " + item_amount( it2 ) + " " + it );
		num = item_amount( it2 );
	}
	
	while( num > 0 )
	{
		visit_url( "curse.php?action=use&pwd&whichitem=" + item_num + "&targetplayer=" + who );
		num = num - 1;
	}
}
 
Last edited:
Thanks for the code. I tried it out today, finally. I used the parameters 99, "roll of toilet paper" and "skent" (my clan leader). The reply I got back was "This item can't be used on other players". I looked and this is item 1923 which is on your list of items in the if statement to determine if it is usable on other players, so I'm trying to ferret out the logic error.

I'll post back if I get it.
 
i hate to necro this thread but i tried using this script w/ the newest version of mafia and get this error:
Code:
Expected ), found < (throw2.ash, line 10)

i got the same error trying to use another script with basically the same function made for 13.2...how would i go about fixing these scripts?
 
When the forum software was converted it turned < into < and > into >

Just change them back.
 
ty

this is the line that throws an error in the other script:
Code:
if( item_num = 1649)

error:
Code:
Expected ), found = (throw.ash, line 17)
 
Last edited:
nvm. Need to realize that there is another page of responses before I post a redundant answer. :(
 
Last edited:
Back
Top