CreatePickup
#1

Does anyone else have a problem with this function?

The pickups that are created outside of OnGameModeInit seem to conflict...

pawn Код:
// OnPlayerKeyStateChange
CashPickup1 = CreatePickup(1212, 2, 500.1288, -76.0403, 998.7578, -1);
CashPickup2 = CreatePickup(1212, 2, 208.2593, -100.4875, 1005.2578, -1);

// OnPlayerPickUpPickup
if(pickupid == CashPickup1)
{
    SendClientMessage(playerid, COLOR, "Pickup 1");
}
else if(pickupid == CashPickup2)
{
    SendClientMessage(playerid, COLOR, "Pickup 2");
}
CashPickup1 seems to be called when CashPickup2 is picked up.
Reply
#2

Is CashPickup1 and CashPickup2 a global variable and check if you manipulate with them anywhere in the script
Reply
#3

They are global and are only used within the two callbacks in the first post.
I remember having this issue a year or two ago, not sure if I ever got round it though.

Edit: I should proberly add this, pickup2 works fine if pickup1 hasn't been picked up before hand.
Reply
#4

pawn Код:
// OnPlayerPickUpPickup
new str[50];
format(str, 50, "pickupid=%d, CashPickup1=%d, CashPickup2=%d", pickupid, CashPickup1, CashPickup2);
SendClientMessage(playerid, COLOR, str);
Try that and you'll see if they IDs really contradict.

Also you do realise you create a new pickup every time you press a key and the id of the previous one is lost because CashPickup1 and CashPickup2 are getting reassigned ?
Reply
#5

They are both calling from id 10 which isn't good.

My OnPlayerKeyStateChange does do some checks for each of them before creating the pickups.
I can't see any fault here..

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    new string[128], wid;
    new SarahNPC = GetPlayerIDFromName ("Sarah");
    new JadeNPC = GetPlayerIDFromName ("Jade");
    new Float:SarahX, Float:SarahY, Float:SarahZ;
    new Float:JadeX, Float:JadeY, Float:JadeZ;
   
    wid = GetPlayerWeapon(playerid);
    GetPlayerPos(SarahNPC, SarahX, SarahY, SarahZ);
    GetPlayerPos(JadeNPC, JadeX, JadeY, JadeZ);
   
    if(IsPlayerInRangeOfPoint(playerid, 10, SarahX, SarahY, SarahZ) && gTeam[playerid] == TEAM_CIVILIAN && wid > 10)
    {
        if(PRESSED(KEY_HANDBRAKE))
        {
            if(IsPlayerFacingPlayer(playerid, SarahNPC, 10) == 1 && SarahNPCHandsUp == 0 && SarahHasBeenRobbed == 0)
            {
                ClearAnimations(SarahNPC);
                SarahNPCHandsUp = 1;
                SarahHasBeenRobbed = 1;
                SetTimer("ResetCPDNPC", 300000, 0);
                ApplyAnimation(SarahNPC, "ped", "handsup", 3.0, 0, 0, 0, 1, 0);
                SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) +2);
                CashPickupForSarah = CreatePickup(1212, 2, 500.1288, -76.0403, 998.7578, -1);
                SetPlayerChatBubble(SarahNPC, "Eeek, take the money!", 0xFFFFFFAA, 50, 5000);
                format(string, sizeof (string), "Crime committed: Robbery. Wanted Level: %d.", GetPlayerWantedLevel(playerid));
                SendClientMessage(playerid, COLOR_SERVER2, string);
                return 1;
            }
        }
        else if(RELEASED(KEY_HANDBRAKE))
        {
            if(IsPlayerFacingPlayer(playerid, SarahNPC, 10) == 1 && SarahHasBeenRobbed == 1 && SarahHiding == 0)
            {
                ClearAnimations(SarahNPC);
                SarahNPCHandsUp = 0;
                SarahHiding = 1;
                ApplyAnimation(SarahNPC, "ON_LOOKERS", "panic_hide", 3.0, 1, 0, 0, 1, 0);
                return 1;
            }
        }
    }
   
    else if(IsPlayerInRangeOfPoint(playerid, 10, JadeX, JadeY, JadeZ) && gTeam[playerid] == TEAM_CIVILIAN && wid > 10)
    {
        if(PRESSED(KEY_HANDBRAKE))
        {
            if(IsPlayerFacingPlayer(playerid, JadeNPC, 10) == 1 && JadeNPCHandsUp == 0 && JadeHasBeenRobbed == 0)
            {
                ClearAnimations(JadeNPC);
                JadeNPCHandsUp = 1;
                JadeHasBeenRobbed = 1;
                SetTimer("ResetCPDNPC", 300000, 0);
                ApplyAnimation(JadeNPC, "ped", "handsup", 3.0, 0, 0, 0, 1, 0);
                SetPlayerWantedLevel(playerid, GetPlayerWantedLevel(playerid) +2);
                JadeCashPickup = CreatePickup(1212, 2, 208.2593, -100.4875, 1005.2578, -1);
                SetPlayerChatBubble(JadeNPC, "Eeek, take the money!", 0xFFFFFFAA, 50, 5000);
                format(string, sizeof (string), "Crime committed: Robbery. Wanted Level: %d.", GetPlayerWantedLevel(playerid));
                SendClientMessage(playerid, COLOR_SERVER2, string);
                return 1;
            }
        }
        else if(RELEASED(KEY_HANDBRAKE))
        {
            if(IsPlayerFacingPlayer(playerid, JadeNPC, 10) == 1 && JadeHasBeenRobbed == 1 && JadeHiding == 0)
            {
                ClearAnimations(JadeNPC);
                JadeNPCHandsUp = 0;
                JadeHiding = 1;
                ApplyAnimation(JadeNPC, "ON_LOOKERS", "panic_hide", 3.0, 1, 0, 0, 1, 0);
                return 1;
            }
        }
    }
    return 1;
}
Reply
#6

Bump after 48hrs.

The problem seems to be DestroyPickup();
It works fine when I remove that function but a separate problem occurs.

As DestroyPickup(); is not being used I have to use a pickup id that will disappear after it has been picked up and not re-spawn. Although every pickup type re-spawns upon interior change.

No idea how to fix this now...
Reply
#7

Quote:
Originally Posted by Infamous
Посмотреть сообщение
The pickups that are created outside of OnGameModeInit seem to conflict...
Thank you! I have been wondering WHY the pickups I create don't appear
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)