Pickup Defines ? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Pickup Defines ? (
/showthread.php?tid=581308)
Pickup Defines ? -
rockhopper - 12.07.2015
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 ?
Re: Pickup Defines ? -
rockhopper - 12.07.2015
Anyone Please ?
AW: Pickup Defines ? -
Nero_3D - 12.07.2015
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
Re: Pickup Defines ? -
rockhopper - 12.07.2015
Thanks Worked