[HELP]Checking if player has picked 2 or more pickups!
#1

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.
Reply
#2

Bump?
Reply
#3

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.
Reply
#4

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?
Reply
#5

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
Reply
#6

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;
}
Reply
#7

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?
Reply
#8

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

then it says you have both
Reply
#9

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!
Reply
#10

Bump!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)