Can i use MAX_PLAYERS for Pickup Ids? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Can i use MAX_PLAYERS for Pickup Ids? (
/showthread.php?tid=166480)
Can i use MAX_PLAYERS for Pickup Ids? -
almighty - 08.08.2010
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...
Re: Can i use MAX_PLAYERS for Pickup Ids? -
Zamaroht - 08.08.2010
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.
Re: Can i use MAX_PLAYERS for Pickup Ids? -
almighty - 08.08.2010
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
Re: Can i use MAX_PLAYERS for Pickup Ids? -
PotH3Ad - 09.08.2010
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;
}
Re: Can i use MAX_PLAYERS for Pickup Ids? -
almighty - 09.08.2010
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