AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Using Multi-Dimensional Arrays with an ID (https://forums.alliedmods.net/showthread.php?t=22645)

Des12 12-31-2005 19:08

Using Multi-Dimensional Arrays with an ID
 
Ok, so I am scripting a hitman plugin, which bascially assigns someone a player to kill, and it stores there id and the target's id in one line.

So would something like this work?

Code:
//in the global declarations new g_hitman[33][33] //in the code g_hitman[id][targetid] //now the ID is assigned by the function, but how would I assign the targetid?

Do you guys understand this? Storing the player's id and his target's id in one multi-dimensional array?

teame06 01-01-2006 01:16

Re: Using Multi-Dimensional Arrays with an ID
 
Quote:

Originally Posted by Des12
Ok, so I am scripting a hitman plugin, which bascially assigns someone a player to kill, and it stores there id and the target's id in one line.

So would something like this work?

Code:
//in the global declarations new g_hitman[33][33] //in the code g_hitman[id][targetid] //now the ID is assigned by the function, but how would I assign the targetid?

Do you guys understand this? Storing the player's id and his target's id in one multi-dimensional array?

You don't need a multi-demensional array for this unless your trying to hold another value or something in there.. You can just do this..


new g_hitman[33]

g_hitman[id] = targetid.

Des12 01-01-2006 10:59

What values can the g_hitman[id] hold? Because I thought the 33 was for the players in the server...no?

teame06 01-01-2006 14:57

Quote:

Originally Posted by Des12
What values can the g_hitman[id] hold? Because I thought the 33 was for the players in the server...no?

yes, 33 was for the players. That first set the size of the array. Then you have 0-32. 0 mean for the server and 1-32 is for the players.

Des12 01-01-2006 15:40

Thank you, but now, when someone dies, it will go to my death_msg function, and how do I check if that person that died was anyone's targetid (as in g_hitman[id] = targetid?

I think I am going to do something like

Code:
//in assigning hitman g_hitman[id] = targetid g_wanted[targetid] = 1

Code:
//when targetid dies if(g_wanted[id] == 1) //code to use g_hitman[id] = targetid, but i dont know how to retrieve //the id, because targetid takes over position of the id :/

v3x 01-01-2006 16:15

I think I know what you're trying to do:
Code:
register_event("DeathMsg", "on_death", "a"); // ... new g_wanted[33], g_hitman[33]; public on_death() {   new victim = read_data(2);   new killer = read_data(1);   if(g_wanted[victim] == 1 && g_hitman[victim] == killer)   {     // the victim was wanted and the the person that just killed him was the hitman that was assigned to him     g_wanted[victim] = 0;     g_hitman[victim] = 0;   } }

Des12 01-01-2006 16:42

Oh I see :D

Thanks v3x 8)


All times are GMT -4. The time now is 15:51.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.