[URGENT]How to respawn destroyed pickup ? I give rep ++ -
buburuzu19 - 28.10.2014
How to re-spawn destroyed pickup ? I created a timer to respawn it but nothing happens
pawn Код:
test[1] = CreatePickup(1242, 8, 1807.5726,-1863.8295,13.5814, -1);
forward PUpdate();
public PUpdate()
(
test[1] = CreatePickup(1242, 8, 1807.5726,-1863.8295,13.5814, -1);
return 1;
}
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == test[1])
{
playeraccount[playerid][Money] += 100000;
DestroyPickup(dovleac[1]);
SetTimer("PUpdate", 100000, 1);
}
}
Re: [URGENT]How to respawn destroyed pickup ? I give rep ++ -
iOxide - 28.10.2014
You don't have to use a timer for that, there are several type of pickups which will appear back after 30 seconds of player picking it up, for example: Pickup type 2. For other pickup types check this link,
https://sampwiki.blast.hk/wiki/PickupTypes
Re: [URGENT]How to respawn destroyed pickup ? I give rep ++ -
buburuzu19 - 28.10.2014
Yes, but i NEED to set them to respawn for 10 Minutes. I am not an idiot but what i did up it doesen't have effect.
And i want to destroy them and re-spawn them because 2 players can pick the same pickup at the same time.
Sorry.
Re: [URGENT]How to respawn destroyed pickup ? I give rep ++ -
MasonSFW - 28.10.2014
Quote:
Use pickup type 2
*Disappears after pickup, respawns after 30 seconds if the player is at a distance of at least 15 meters.
|
pawn Код:
new Pickup1;
Public OnGameModeInit()
{
Pickup1 = CreatePickup(1242, 2, 1807.5726,-1863.8295,13.5814, -1);
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == Pickup1)
{
playeraccount[playerid][Money] += 100000;
}
}
Re: [URGENT]How to respawn destroyed pickup ? I give rep ++ -
buburuzu19 - 28.10.2014
Quote:
Originally Posted by MasonSFW
pawn Код:
new Pickup1;
Public OnGameModeInit() { Pickup1 = CreatePickup(1242, 2, 1807.5726,-1863.8295,13.5814, -1); return 1; }
public OnPlayerPickUpPickup(playerid, pickupid) { if(pickupid == Pickup1) { playeraccount[playerid][Money] += 100000; } }
|
Quote:
Originally Posted by buburuzu19
Yes, but i NEED to set them to respawn for 10 Minutes. I am not an idiot but what i did up it doesen't have effect.
And i want to destroy them and re-spawn them because 2 players can pick the same pickup at the same time.
Sorry.
|
You didn't read.
Re: [URGENT]How to respawn destroyed pickup ? I give rep ++ -
MasonSFW - 28.10.2014
pawn Код:
new Pickups[MAX_PLAYERS];
public OnPlayerSpawn(playerid)
{
Pickups[playerid] = CreatePickup(1242, 23, 1807.5726,-1863.8295,13.5814, -1);
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
if(pickupid == Pickups[playerid])
{
playeraccount[playerid][Money] += 100000;
DestroyPickup(Pickups[playerid]);
SetTimerEx("RenewPickup", 100000, false, "i", playerid); //10 Minutes to respawn pickup
}
return 1;
}
public RenewPickup(playerid)
{
Pickups[playerid] = CreatePickup(1242, 23, 1807.5726,-1863.8295,13.5814, -1);
return 1;
}
Re: [URGENT]How to respawn destroyed pickup ? I give rep ++ -
buburuzu19 - 28.10.2014
I used your code so here is my new problem:
- I want to add more than 1 pickup who will do the same thing because i am making an pickup event.
- I added new test[40][MAX_PLAYERS]; because i will create 40 pickups
- pickupid == test[playerid][1]
- DestroyPickup(test[playerid][1]);
- On Pupdate() i added
test[playerid][1] = CreatePickup(19320, 8, 1807.5726,-1863.8295,13.5814, -1);
Now the problem is , if i pick up for the first time and after i wait 1 sec for example, i enter again in checkpoint , he disappers and nothing happens...
Re: [URGENT]How to respawn destroyed pickup ? I give rep ++ -
buburuzu19 - 28.10.2014
I discovered that after the timer renews the pickup , the function OnPlayerPickupPickup stop working.
If i respawn me with the cmd /respawn it works.
Re: [URGENT]How to respawn destroyed pickup ? I give rep ++ -
Quickie - 28.10.2014
i just made a code 4 u
hope it will give u an idea
i didnt test the code yet
pawn Код:
#define INVALID_PICKUP 999999999 //defining invalid pickup
new pickupEvent;
new pickup[40];
new pickupPos[][4]=
{
{x,y,z,pickuptype),// ur pickup statistics ,, we will use it late for loop on creating pickup
{x,y,z,pickuptype},...//and so on
}
stock destroyEventPickup()
{
for(new i;i!=sizeof(pickup);i++)
{
if(pickup[i]!=INVALID_PICKUP)
{
DestroyPickup(pickup[i]);
pickup[i]=INVALID_PICKUP;
}
}
pickupevent=0;
}
stock createEventPickup()
{
for(newi;i!=sizeof(pickup);i++)
{
pickup[i]=CreatePickup(pickupPos[i][3],pickupPos[i][0],pickupPos[i][1],pickupPos[i][2]);
}
pickupevent=1;
}
CMD:startpickupevent(playerid,paramd)
{
if(pickupEvent==1)return SendClientMessage(playerid,-1," Event already begun type /stoppickupevent to close the event");
createEventPickup();
SendClientMessageToAll(color,"admin has opened the pickup event");
return 1;
}
CMD:stoppickupevent(playerid,paramd)
{
if(pickupEvent==0)return SendClientMessage(playerid,-1," we dont have an existing pickup event to close type /startpickupevent to start a new one ");
destroyEventPickup();
SendClientMessageToAll(color,"admin has closed the pickup event");
return 1;
}
public OnPlayerPickupPickup(playerid,pickupid)
{
if(pickupEvent==1)
{
for(new i;i!=sizeof(pickup);i++)
{
if(pickup==pickup[i])
{
new string[128],pname[25];
DestroyPickup(pickup[i]);
pickup[i]=INVALID_PICKUP;
GetPlayerName(playerid,pname,sizeof(pname));
format(string,sizeof(string)," %s(%d) pickup the pickup id: %d",pname,playerid,i);
SendClientMessageToAll(-1,string);
// ur code goes here
// do something
}
}
}
return 1;
}
hope u like it
Re: [URGENT]How to respawn destroyed pickup ? I give rep ++ -
buburuzu19 - 28.10.2014
Quote:
Originally Posted by Quickie
i just made a code 4 u
hope it will give u an idea
i didnt test the code yet
pawn Код:
#define INVALID_PICKUP 999999999 //defining invalid pickup new pickupEvent; new pickup[40]; new pickupPos[][4]= { {x,y,z,pickuptype),// ur pickup statistics ,, we will use it late for loop on creating pickup {x,y,z,pickuptype},...//and so on } stock destroyEventPickup() { for(new i;i!=sizeof(pickup);i++) { if(pickup[i]!=INVALID_PICKUP) { DestroyPickup(pickup[i]); pickup[i]=INVALID_PICKUP; } } pickupevent=0; } stock createEventPickup() { for(newi;i!=sizeof(pickup);i++) { pickup[i]=CreatePickup(pickupPos[i][3],pickupPos[i][0],pickupPos[i][1],pickupPos[i][2]); } pickupevent=1; } CMD:startpickupevent(playerid,paramd) { if(pickupEvent==1)return SendClientMessage(playerid,-1," Event already begun type /stoppickupevent to close the event"); createEventPickup(); SendClientMessageToAll(color,"admin has opened the pickup event"); return 1; } CMD:stoppickupevent(playerid,paramd) { if(pickupEvent==0)return SendClientMessage(playerid,-1," we dont have an existing pickup event to close type /startpickupevent to start a new one "); destroyEventPickup(); SendClientMessageToAll(color,"admin has closed the pickup event"); return 1; } public OnPlayerPickupPickup(playerid,pickupid) { if(pickupEvent==1) { for(new i;i!=sizeof(pickup);i++) { if(pickup==pickup[i]) { new string[128],pname[25]; DestroyPickup(pickup[i]); pickup[i]=INVALID_PICKUP; GetPlayerName(playerid,pname,sizeof(pname)); format(string,sizeof(string)," %s(%d) pickup the pickup id: %d",pname,playerid,i); SendClientMessageToAll(-1,string);
// ur code goes here // do something } } } return 1; }
hope u like it
|
My system is very very different btw, my only problem is destroying and respawning the pickup , the timer has no effect. Other answers?