Pickup Defines ?
#1

Okay so I wanna make a collecting game in which I placed 100 pickups I want them to be Pickups[100] And I did All 100 pickups as Pickups[0] = CreatePickup etc etc . So I want onplayerpickup here and when that happens the pickup should disappear and a player should get a message like Stuff Collect = %s where %s = PickupsPicked
where new PickupPicked;
And I want like when the player picks the pickup Pickups[100] All 100 here then PickupsPicked ++; and I wanna Output it to the player like You picked 2 pickups. So how do I do this ?
Reply
#2

Anyone Please ?
Reply
#3

If its some kind of game you should put it in a function like that
pawn Код:
new Pickups[100] = {-1, ...}; // Initialize this array with -1 or any other invalid pickupid
new PickupsPicked[MAX_PLAYER];

CreateColPickups() {
    for(new p; p < sizeof Pickups; ++p) {
        Pickups[p] = CreatePickup(...);
    }
    new
        zero[sizeof PickupsPicked]
    ;
    PickupsPicked = zero;
}
You need to use OnPlayerPickUpPickup, check if the player picked up one of the 100
pawn Код:
//OnPlayerPickUpPickup(playerid, pickupid)
    for(new p; p < sizeof Pickups; ++p) {
        if(pickupid == Pickups[p]) {
            // for easier structure I use a seperate function
            return OnPlayerPickUpColPickup(playerid, pickupid, p);
        }
    }
Do in your function whatever you want
pawn Код:
OnPlayerPickUpColPickup(playerid, pickupid, idx) {
    new
        string[128]
    ;
    GetPlayerName(playeird, string, MAX_PLAYER_NAME);
    format(string, sizeof string, "%s found one pickup!", string);
    SendClientMessageToAll(0xFF0000FF, string);

    PickupsPicked[playerid]++;

    if(PickupsPicked[playerid] == 1) {
        string = "You picked up 1 pickup!";
    } else {
        format(string, sizeof string, "You picked up %d pickups", PickupsPicked[playerid]);
    }
    SendClientMessage(playerid, 0xFF0000FF, string);

    Pickups[idx] = -1; // mark this index as invalid pickupid
    return DestroyPickup(pickupid);
}
Something like that I guess
Reply
#4

Thanks Worked
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)