Can i use MAX_PLAYERS for Pickup Ids?
#1

Im making a Script... And i want to make so when a player dies, he drops some cash.... actually 1 pickup for each player... i was wondering if i could use something like this

Pickupid[playerid] = CreatePickup(...)...

And will it work if i put it OnPlayerPickupPickup

if pickupid == Pickupid[playerid]...

i've tried... didnt work so i erased and started a new system.... but i was wondering if there is a way to do it this way...
Reply
#2

Yes, you can do it that way, but:

if pickupid == Pickupid[playerid]

Think a bit more about that line. That basicly means that the only player able to pickup the bag is the same player who died.
Reply
#3

I dont understand... i mean... the way i see it, its suppose to set the Pickup id to for example, Player who died is id 0 then the pickup id would be Pickupid[0], right?... That way i cant handle several pickups with only a few lines of code... or im wrong?...

OffTopic: This is so i can avoid another topic... But, How much time a Deathmatch Game Should last?... Meaning, i have other Gametypes available
Reply
#4

Well you can just use a loop:

pawn Код:
public OnPlayerPickupPickup(playerid, pickupid)
{
    for(new x=0; x<MAX_PLAYERS; x++)
    {
        if(pickupid == Pickupid[x])
        {
            //Do something here
            break; //Stop the loop
        }
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by ******
Посмотреть сообщение
No - that's exactly correct. The issue is not creating pickups, it's picking them up again:

Player 3 dies - Pickupid[3] now has their pickup
Player 7 picks up a pickup - your code will thus check Pickupid[7], which is not the same one.

You need to loop through all players (I suggest using foreach).
Thank you... after a bit of tought i got to that conclusion... i desided to eliminate pickups and just give the killer half the money of the killed... its just remporary... as i want to first get the script up and running... i will... I was reading about a while ago... Thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)