12.07.2015, 10:56
If its some kind of game you should put it in a function like that
You need to use OnPlayerPickUpPickup, check if the player picked up one of the 100
Do in your function whatever you want
Something like that I guess
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;
}
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);
}
}
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);
}