OnPlayerPickUpPickup
#1

Код:
new Moneybag1;
new Moneybag2;
new Moneybag3;
MR()
{
	new mbrand = random(3);
	if(mbrand == 0)
	{
	    MB1();
 	}
	else if(mbrand == 1)
	{
	    MB2();
	}
	else if(mbrand == 2)
	{
	    MB3();
	}
}
MB1()
{
	Moneybag1 = CreatePickup(1550, 2, -435.7654,-60.1194,58.8750);//  The Panopticon In Small Garage
	SendClientMessageToAll(green, "Money Rush! A Money Bag has been dropped in The Panoption.");
}
MB2()
{
	Moneybag2 = CreatePickup(1550, 2, 571.3318,824.5909,-29.8438);//  Hunter Quarry Under Ladder
	SendClientMessageToAll(green, "Money Rush! A Money Bag has been dropped in Hunter Quarry.");
}
MB3()
{
	Moneybag3 = CreatePickup(1550, 2, -2374.7766,2215.7478,4.9844);// Bayside Behind Light House
	SendClientMessageToAll(green, "Money Rush! A Money Bag has been dropped in Bayside.");
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
    new name[MAX_PLAYER_NAME];
    new string[128];
    if(pickupid == Moneybag2)
	{
	    GetPlayerName(playerid, name, sizeof(name));
		format(string, sizeof(string), "%s (%i) has Found the Lost Money Bag in The Hunter Quarry that Worth $180000.",name,playerid);
		SendClientMessageToAll(green, string);
		GivePlayerMoney(playerid, 180000);
	}
	else if(pickupid == Moneybag3)
	{
		GetPlayerName(playerid, name, sizeof(name));
		format(string, sizeof(string), "%s (%i) has Found the Lost Money Bag in Bayside that Worth $200000.",name,playerid);
		SendClientMessageToAll(green, string);
		GivePlayerMoney(playerid, 200000);
	}
	else if(pickupid == Moneybag1)
	{
	    GetPlayerName(playerid, name, sizeof(name));
		format(string, sizeof(string), "%s (%i) has Found the Lost Money Bag in The Panoption that Worth $240000.",name,playerid);
		SendClientMessageToAll(green, string);
		GivePlayerMoney(playerid, 240000);
	}
	DestroyMR();
}
DestroyMR()
{
	DestroyPickup(Moneybag1);
	DestroyPickup(Moneybag2);
	DestroyPickup(Moneybag3);
}
everytime i pickup a "money bag" it says i have found it in The Hunter Quarry. it doesnt save the pickup id for some reason i think?

and if i switch the else if with if in onplayerpickup it sends all the three messages and gives me money for the 3 money bags.

pls help guys i cant figure this shit out... =(
Reply
#2

Hmm weird. Should work.

I'll try to find a fix
Reply
#3

its like the pickup id doesnt save or anything... maybe im missing a return somewhere? ive been trying to fix this before already... nothing works
Reply
#4

bump^^^^
Reply
#5

How many times have you tested it in a row? It seems that random is always returning "2" out of luck.
Reply
#6

Its really have to work...
Maybe you can create a global var like this:
Код:
new Moneybag1;
new Moneybag2;
new Moneybag3;
new bag;
MR()
{
	new mbrand = random(3);
	if(mbrand == 0)
	{
	    MB1();
 	}
	else if(mbrand == 1)
	{
	    MB2();
	}
	else if(mbrand == 2)
	{
	    MB3();
	}
}
MB1()
{
	Moneybag1 = CreatePickup(1550, 2, -435.7654,-60.1194,58.8750);//  The Panopticon In Small Garage
	SendClientMessageToAll(green, "Money Rush! A Money Bag has been dropped in The Panoption.");
        bag = 1;
}
MB2()
{
	Moneybag2 = CreatePickup(1550, 2, 571.3318,824.5909,-29.8438);//  Hunter Quarry Under Ladder
	SendClientMessageToAll(green, "Money Rush! A Money Bag has been dropped in Hunter Quarry.");
        bag = 2;
}
MB3()
{
	Moneybag3 = CreatePickup(1550, 2, -2374.7766,2215.7478,4.9844);// Bayside Behind Light House
	SendClientMessageToAll(green, "Money Rush! A Money Bag has been dropped in Bayside.");
        bag = 3;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
    new name[MAX_PLAYER_NAME];
    new string[128];
    if(pickupid == 1550)
{
if (bag == 1)
	{
	    GetPlayerName(playerid, name, sizeof(name));
		format(string, sizeof(string), "%s (%i) has Found the Lost Money Bag in The Hunter Quarry that Worth $180000.",name,playerid);
		SendClientMessageToAll(green, string);
		GivePlayerMoney(playerid, 180000);
	}
	else if(bag == 2)
	{
		GetPlayerName(playerid, name, sizeof(name));
		format(string, sizeof(string), "%s (%i) has Found the Lost Money Bag in Bayside that Worth $200000.",name,playerid);
		SendClientMessageToAll(green, string);
		GivePlayerMoney(playerid, 200000);
	}
	else if(bag == 3)
	{
	    GetPlayerName(playerid, name, sizeof(name));
		format(string, sizeof(string), "%s (%i) has Found the Lost Money Bag in The Panoption that Worth $240000.",name,playerid);
		SendClientMessageToAll(green, string);
		GivePlayerMoney(playerid, 240000);
	}
}
	DestroyMR();
}
DestroyMR()
{
	DestroyPickup(Moneybag1);
	DestroyPickup(Moneybag2);
	DestroyPickup(Moneybag3);
        bag == 0;
}
Reply
#7

The last part:
pawn Код:
DestroyMR()
{
    DestroyPickup(Moneybag1);
    DestroyPickup(Moneybag2);
    DestroyPickup(Moneybag3);
        bag == 0;
}
Will give you errors, you only use a double equal sign on a if/else/else-if statement.
bag = 0;
Don't know about the rest of the code though.
Reply
#8

You might want to try this:

Код:
new mbrand;

new Moneybag1;
new Moneybag2;
new Moneybag3;

stock MR()
{
	mbrand = 1+ random(2);
	if(mbrand == 1)
	{
	    	MB1();
 	}
	if(mbrand == 2)
	{
	    	MB2();
	}
	if(mbrand == 3)
	{
	    	MB3();
	}
	return 1;
}
stock MB1()
{
	Moneybag1 = CreatePickup(1550, 2, -435.7654,-60.1194,58.8750);//  The Panopticon In Small Garage
	return SendClientMessageToAll(green, "Money Rush! A Money Bag has been dropped in The Panoption.");
}
stock MB2()
{
	Moneybag2 = CreatePickup(1550, 2, 571.3318,824.5909,-29.8438);//  Hunter Quarry Under Ladder
	return SendClientMessageToAll(green, "Money Rush! A Money Bag has been dropped in Hunter Quarry.");
}
stock MB3()
{
	Moneybag3 = CreatePickup(1550, 2, -2374.7766,2215.7478,4.9844);// Bayside Behind Light House
	return SendClientMessageToAll(green, "Money Rush! A Money Bag has been dropped in Bayside.");
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
    	new name[MAX_PLAYER_NAME];
    	new string[128];

	GetPlayerName(playerid,name,sizeof(name));
	
	if(pickupid == Moneybag1)
	{
		format(string, sizeof(string), "%s (%d) has Found the Lost Money Bag in The Panoption that Worth $240000.",name,playerid);
		GivePlayerMoney(playerid, 240000);
	}
	if(pickupid == Moneybag2)
	{
		format(string, sizeof(string), "%s (%d) has Found the Lost Money Bag in The Hunter Quarry that Worth $180000.",name,playerid);
		GivePlayerMoney(playerid, 180000);
	}
	else if(pickupid == Moneybag3)
	{
		format(string, sizeof(string), "%s (%d) has Found the Lost Money Bag in Bayside that Worth $200000.",name,playerid);
		GivePlayerMoney(playerid, 200000);
	}

	SendClientMessageToAll(green, string);

	DestroyMR();
}
stock DestroyMR()
{
	DestroyPickup(Moneybag1);
	DestroyPickup(Moneybag2);
	DestroyPickup(Moneybag3);
	return 1;
}
Reply
#9

ty every1, ill try test that and reply back if it works
Reply
#10

tnx for help guys, i modified it a little bit cause no one's code was working. This works fine !
Код:
MR()
{
	new mbrand = random(3);
	if(mbrand == 0)
	{
	    MB1();
 	}
	else if(mbrand == 1)
	{
	    MB2();
	}
	else if(mbrand == 2)
	{
	    MB3();
	}
}
MB1()
{
	Moneybag = CreatePickup(1550, 2, -435.7654,-60.1194,58.8750);//  The Panopticon In Small Garage
	SendClientMessageToAll(green, "Money Rush! A Money Bag has been dropped in The Panopticon.");
	bag = 3;
}
MB2()
{
	Moneybag = CreatePickup(1550, 2, 571.3318,824.5909,-29.8438);//  Hunter Quarry Under Ladder
	SendClientMessageToAll(green, "Money Rush! A Money Bag has been dropped in Hunter Quarry.");
	bag = 1;
}
MB3()
{
	Moneybag = CreatePickup(1550, 2, -2374.7766,2215.7478,4.9844);// Bayside Behind Light House
	SendClientMessageToAll(green, "Money Rush! A Money Bag has been dropped in Bayside.");
	bag = 2;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
    new name[MAX_PLAYER_NAME];
    new string[128];
    if(pickupid == Moneybag)
	{
		if(bag == 1)
		{
		    GetPlayerName(playerid, name, sizeof(name));
			format(string, sizeof(string), "%s (%i) Has Found the Lost Money Bag in The Hunter Quarry that Worth $180000.",name,playerid);
			SendClientMessageToAll(green, string);
			GivePlayerMoney(playerid, 180000);
		}
		else if(bag == 2)
		{
			GetPlayerName(playerid, name, sizeof(name));
			format(string, sizeof(string), "%s (%i) Has Found the Lost Money Bag in Bayside that Worth $200000.",name,playerid);
			SendClientMessageToAll(green, string);
			GivePlayerMoney(playerid, 200000);
		}
		else if(bag == 3)
		{
		    GetPlayerName(playerid, name, sizeof(name));
			format(string, sizeof(string), "%s (%i) Has Found the Lost Money Bag in The Panopticon that Worth $240000.",name,playerid);
			SendClientMessageToAll(green, string);
			GivePlayerMoney(playerid, 240000);
		}
	}
	DestroyMR();
}
DestroyMR()
{
	DestroyPickup(Moneybag);
 	bag = 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)