SA-MP Forums Archive
[HELP]Checking if player has picked 2 or more pickups! - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP]Checking if player has picked 2 or more pickups! (/showthread.php?tid=133057)



[HELP]Checking if player has picked 2 or more pickups! - Epic Shower - 10.03.2010

I'm having a problem making a message appear right after a player picks 2 certain pickups.
I did this has you can see:

Код:
     new bag;
     new suitcase;

    bag = CreatePickup(1550, 3, 2144.0920,1640.4911,993.5761);
    suitcase = CreatePickup(1210, 3, 2218.3157,1613.3298,999.9
    

    if(pickupid == suitcase, bag) {
	new string[48];
	new playername[MAX_PLAYER_NAME];
	GetPlayerName(playerid, playername, 24);
	format(string, sizeof(string), " %s has robbed 150000$ from Caligula's!", playername );
	SendClientMessageToAll(COLOR_RED, string);
	SendClientMessage(playerid, COLOR_RED,"------------------------------------------------------------------");
	SendClientMessage(playerid, COLOR_WHITE,"Both suitcase and bag have been stolen.");
	SendClientMessage(playerid, COLOR_GREEN,"Escape the Casino!");
	SendClientMessage(playerid, COLOR_RED,"------------------------------------------------------------------");
	return 1;
	}
The message appears after i picked up both of the pickups but, not right away it takes a while for it to show the message :/
Am i doing something wrong here or it isn't possible to make a message appear right away once i have picked up the 2 pickups?

Please help.


Re: [HELP]Checking if player has picked 2 or more pickups! - Epic Shower - 11.03.2010

Bump?


Re: [HELP]Checking if player has picked 2 or more pickups! - adsy - 11.03.2010

basically you arent declaring it correctly

you cannot use this: if(pickupid == suitcase, bag) {

if you want to have it show then you will probably have to assign each one a second variable on pickup

if(pickupid == suitcase) {

if(pickupid == bag) {

the problem is you cant pickup more than 1 item at a time so you need to store in the script what and who has picked it up.

stick another if in there to check if the player already picked one up and if so then on the second one you get the messages you want.


Re: [HELP]Checking if player has picked 2 or more pickups! - Epic Shower - 12.03.2010

Your right about the:
if(pickupid == suitcase, bag) {

Anyway, I already have the if(pickupid == suitcase) { and if(pickupid == bag) { functions.
But i want it to be once you have picked up suitcase and then the bag a message will appear saying that i have picked up the required pickups.

Quote:
Originally Posted by adsy
stick another if in there to check if the player already picked one up and if so then on the second one you get the messages you want.
How do i do that?


Re: [HELP]Checking if player has picked 2 or more pickups! - Conroy - 12.03.2010

Never tried an IF statement like that, I've always used this:

pawn Код:
if(pickupid == suitcase || pickupid == bag) {
// "||" means OR

if(pickupid == suitcase && pickupid == bag) {
// "&&" means AND



Re: [HELP]Checking if player has picked 2 or more pickups! - adsy - 12.03.2010

Quote:
Originally Posted by Conroy
Never tried an IF statement like that, I've always used this:

pawn Код:
if(pickupid == suitcase || pickupid == bag) {
// "||" means OR

if(pickupid == suitcase && pickupid == bag) {
// "&&" means AND
as i previously stated

it is not possible to pickup 2 items at the same time

lets see

something like
Код:
if(pickupid == suitcase){
if(itemspickedup == 1){
SendClientMessage(playerid, COLOUR, "message");
}
else{
itemspickedup = 1;
}
}
if(pickupid == bag)
if(itemspickedup == 1){
SendClientMessage(playerid, COLOUR, "message");
}
else{
itemspickedup = 1;
}



Re: [HELP]Checking if player has picked 2 or more pickups! - Epic Shower - 14.03.2010

Quote:
Originally Posted by adsy
Код:
if(pickupid == suitcase){
if(itemspickedup == 1){
SendClientMessage(playerid, COLOUR, "message");
}
else{
itemspickedup = 1;
}
}
if(pickupid == bag)
if(itemspickedup == 1){
SendClientMessage(playerid, COLOUR, "message");
}
else{
itemspickedup = 1;
}
Can you please explain what is it going to do exactly?


Re: [HELP]Checking if player has picked 2 or more pickups! - adsy - 14.03.2010

each one sets that 1 item has been picked up unless 1 already has

then it says you have both


Re: [HELP]Checking if player has picked 2 or more pickups! - Epic Shower - 14.03.2010

Quote:
Originally Posted by adsy
each one sets that 1 item has been picked up unless 1 already has

then it says you have both
Still doesn't work!



Re: [HELP]Checking if player has picked 2 or more pickups!---CLOSED--- - Epic Shower - 18.03.2010

Bump!