Pickups spam - 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)
+--- Thread: Pickups spam (
/showthread.php?tid=602278)
Pickups spam -
Uberanwar - 05.03.2016
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?
Re: Pickups spam -
SickAttack - 05.03.2016
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
Re: Pickups spam -
itsCody - 05.03.2016
You could do something like this..
PHP код:
new PickupTimer[MAX_PLAYERS], ActivePickup[MAX_PLAYERS] = INVALID_PICKUP_ID, Test_Pickup;
forward Pickup_Cooldown();
#define INVALID_PICKUP_ID 0xFFFF
#define DIALOG_TEST 1337
public OnGameModeInit()
{
SetTimer("Pickup_Cooldown", 999, 1);
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(ActivePickup[playerid] == INVALID_PICKUP_ID)
{
if(pickupid == Test_Pickup)
{
ShowPlayerDialog(playerid, DIALOG_TEST, 2, "", "", "", "");
ActivePickup[playerid] = pickupid;
}
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
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 i = 0; i < MAX_PLAYERS; i ++)
{
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.
Re: Pickups spam -
SickAttack - 05.03.2016
Quote:
Originally Posted by itsCody
You could do something like this..
PHP код:
new PickupTimer[MAX_PLAYERS], ActivePickup[MAX_PLAYERS] = INVALID_PICKUP_ID, Test_Pickup;
forward Pickup_Cooldown();
#define INVALID_PICKUP_ID 0xFFFF
#define DIALOG_TEST 1337
public OnGameModeInit()
{
SetTimer("Pickup_Cooldown", 999, 1);
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(ActivePickup[playerid] == INVALID_PICKUP_ID)
{
if(pickupid == Test_Pickup)
{
ShowPlayerDialog(playerid, DIALOG_TEST, 2, "", "", "", "");
ActivePickup[playerid] = pickupid;
}
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
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 i = 0; i < MAX_PLAYERS; i ++)
{
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.
Re: Pickups spam -
xTURBOx - 05.03.2016
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;
}
Re: Pickups spam -
itsCody - 05.03.2016
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.