Pickups spam
#1

Hi everyone,
I use pickups instead of checkpoints for shops dialog menu, etc.. when I go to a pickup, it spams the dialog.
it still appears when I click cancel on the dialog. keeps appearing again and again, making it hard to leave the pickup..
so how do i fix this?
Reply
#2

Pickups are like use.

You can change the pickup type, but it will be annoying since you would have to wait a bit for it to reappear.

https://sampwiki.blast.hk/wiki/PickupTypes
Reply
#3

You could do something like this..
PHP код:
new PickupTimer[MAX_PLAYERS], ActivePickup[MAX_PLAYERS] = INVALID_PICKUP_IDTest_Pickup;
forward Pickup_Cooldown();
#define INVALID_PICKUP_ID 0xFFFF
#define DIALOG_TEST 1337
public OnGameModeInit()
{
    
SetTimer("Pickup_Cooldown"9991);
    return 
1;
}
public 
OnPlayerPickUpPickup(playeridpickupid)
{
    if(
ActivePickup[playerid] == INVALID_PICKUP_ID)
    {
        if(
pickupid == Test_Pickup)
        {
            
ShowPlayerDialog(playeridDIALOG_TEST2"""""""");
            
ActivePickup[playerid] = pickupid;
        }
    }
    return 
1;
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    if(
dialogid == DIALOG_TEST)
    {
        
PickupTimer[playerid] = 5// 5 seconds
        
        
if(response)
        {
            if(
ActivePickup[playerid] == Test_Pickup)
            {
                
// do stuff
            
}
        }
    }
    return 
1;
}
public 
Pickup_Cooldown()
{
    for(new 
0MAX_PLAYERS++)
    {
        if(
PickupTimer[i] > 1)
            
PickupTimer[i] --;
            
        if(
PickupTimer[i] == 1)
        {
            
PickupTimer[i] = 0;
            if(
ActivePickup[i] != INVALID_PICKUP_ID)
                
ActivePickup[i] = INVALID_PICKUP_ID;
        }
    }

That's how I always did mine when using pickups that bring up dialogs, but don't use my example in your script because it's poorly done and can be made way more efficient and better.
Reply
#4

Quote:
Originally Posted by itsCody
Посмотреть сообщение
You could do something like this..
PHP код:
new PickupTimer[MAX_PLAYERS], ActivePickup[MAX_PLAYERS] = INVALID_PICKUP_IDTest_Pickup;
forward Pickup_Cooldown();
#define INVALID_PICKUP_ID 0xFFFF
#define DIALOG_TEST 1337
public OnGameModeInit()
{
    
SetTimer("Pickup_Cooldown"9991);
    return 
1;
}
public 
OnPlayerPickUpPickup(playeridpickupid)
{
    if(
ActivePickup[playerid] == INVALID_PICKUP_ID)
    {
        if(
pickupid == Test_Pickup)
        {
            
ShowPlayerDialog(playeridDIALOG_TEST2"""""""");
            
ActivePickup[playerid] = pickupid;
        }
    }
    return 
1;
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    if(
dialogid == DIALOG_TEST)
    {
        
PickupTimer[playerid] = 5// 5 seconds
        
        
if(response)
        {
            if(
ActivePickup[playerid] == Test_Pickup)
            {
                
// do stuff
            
}
        }
    }
    return 
1;
}
public 
Pickup_Cooldown()
{
    for(new 
0MAX_PLAYERS++)
    {
        if(
PickupTimer[i] > 1)
            
PickupTimer[i] --;
            
        if(
PickupTimer[i] == 1)
        {
            
PickupTimer[i] = 0;
            if(
ActivePickup[i] != INVALID_PICKUP_ID)
                
ActivePickup[i] = INVALID_PICKUP_ID;
        }
    }

That's how I always did mine when using pickups that bring up dialogs, but don't use my example in your script because it's poorly done and can be made way more efficient and better.
He's better off using checkpoints than using that (I'm aware of you saying it's not efficient, and I totally agree). But if he wants to use pickups, he should use areas that comes in the streamer plugin instead (OnPlayerPickUpPickup becomes obsolete).

The pickup would just be a "decoration", it won't actually do anything. The areas will do all the work.
Reply
#5

Use a timer + variable?
here is an idea
Код:
new variable[MAX_PLAYERS];

OnPlayerPickUpPickup(//)
if(variable[playerid] == 0)
{
showplayerdialog(//)
variable[playerid] = 1;
settimerex("resetvariable",10000,false,"i",playerid);
}

forward resetvariable(playerid);
public resetvariable(playerid)
{
variable[playerid] = 0;
}
Reply
#6

Quote:
Originally Posted by xTURBOx
Посмотреть сообщение
Use a timer + variable?
here is an idea
Код:
new variable[MAX_PLAYERS];

OnPlayerPickUpPickup(//)
if(variable[playerid] == 0)
{
showplayerdialog(//)
variable[playerid] = 1;
settimerex("resetvariable",10000,false,"i",playerid);
}

forward resetvariable(playerid);
public resetvariable(playerid)
{
variable[playerid] = 0;
}
That wouldn't work out good at all.

But yeah, I would just recommend checkpoints or what Sick said above for the different pickup types.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)