PDA

View Full Version : ClientMessage Problem


Juanxz
12/06/2013, 01:45 AM
Hi, after some time trying to fix it by myself...I gave up.
Below is a menu where I can spawn three types of drugs, each one giving a message.
My problem is that on the first pickup, it displays each drug message separately but later on it displays all three messages under 1 pickup.
For example I pickup Drug1 and I get 3 messages, one for each drug. Strange problem.


if(pickupid == Drug1)
{
haveweed[playerid] = 1;
SendClientMessage(playerid, GREEN, "You picked up Weed, type /useeweed to use!");
DestroyPickup(Drug1);
}
if(pickupid == Drug2)
{
haveecstasy[playerid] = 1;
SendClientMessage(playerid, GREEN, "You picked up Ecstasy, type /useecstasy to use!");
DestroyPickup(Drug2);
}
if(pickupid == Drug3)
{
haveheroin[playerid] = 1;
SendClientMessage(playerid, GREEN, "You picked up Heroin, type /useheroin to use!");
DestroyPickup(Drug3);
}


Can anyone help?

BossZk
12/06/2013, 01:50 AM
if(pickupid == Drug1)
{
haveweed[playerid] = 1;
SendClientMessage(playerid, GREEN, "You picked up Weed, type /useeweed to use!");
DestroyPickup(Drug1);
}
else if(pickupid == Drug2)
{
haveecstasy[playerid] = 1;
SendClientMessage(playerid, GREEN, "You picked up Ecstasy, type /useecstasy to use!");
DestroyPickup(Drug2);
}
else if(pickupid == Drug3)
{
haveheroin[playerid] = 1;
SendClientMessage(playerid, GREEN, "You picked up Heroin, type /useheroin to use!");
DestroyPickup(Drug3);
}

i think that should solve it

Stereotype
12/06/2013, 02:18 AM
Yes , that is problem for sure ....

[KHK]Khalid
12/06/2013, 02:51 AM
Pickup IDs are messed up. Here when you destroy Drug1 pickup, Drug2 takes its place (takes the ID of Drug1) thus it's read as Drug1 as well. Store pickups info in an array or give this include a try (http://forum.sa-mp.com/showthread.php?t=46645).

Juanxz
13/06/2013, 10:22 AM
@Khalid
I used the include provided above, thanks for that. The pickups seem to be running better.

@BossZk
By adding the "else", I ended up going back to an earlier problem I had when the pickup would only register for one drug (the first one used) meaning if I pickup weed and then ecstasy...it gives me the same effects of weed including the "haveecstasy[playerid] = 1;" array.

I eventually by-passed the problem by removing the text with these pickups.
Thanks all for your help!