Assign a value to a pickupid ??
#1

Hey guys,
Actually it's possible to do that :

new var[MAX_PLAYERS];
var[playerid] == value;

But how do that stuff from a location (pickup)?
Let me explain,
I want to use a fuel system, but i want to to something like :

fuel[pickupid] == value;

This could be useful to create a job to refill gas station

How to do please ??
__________________
Reply
#2

pawn Код:
new var[MAX_PICKUPS];
var[pickupid] == value
Pretty simple
Reply
#3

Did you mean't this?
pawn Код:
var[playerid] = CreatePickup(...);
Reply
#4

have a look at the CreatePickup function - it returns the ID of the created pickup. you need to store it at some place to use it as pointer for your fuel system.
when you start like
pawn Код:
new IsAFuelPickupID[MAX_PICKUPS]; //this name is easier to read than just "fuel"
..and create the pickup at any place in the script..
pawn Код:
new FreshID=CreatePickup(coords and type etc);
..then you can use that FreshID value (the pickupid lateron) to serve as a POINTER into another cell, your IsAFuelPickupID[]. this can look like
pawn Код:
IsAFuelPickupID[FreshID]=1;// a possible mission target? gallons to be delivered?
anything is possible, since you use the pickupid as a pointer into another array - the array size NEEDS to be equal or bigger in size of the pickups amount. but thats why i <3 trading (a few used) RAM for (a LOT saved) CPU usage: the pickupid can, and will, directly point into the cell of your array. no loop required like
pawn Код:
for(new pid=0;0<MAX_PICKUPS;pid++){
if(pickupid==IsFuelPickup[pid])
playerIDs and pickupIDs are basically acting the same: dynamic. you never know which pickup got which ID. when touching a pickup, you at least know its ID...
Reply
#5

Thank you so muck guys!!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)