AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Modifying Entities (https://forums.alliedmods.net/showthread.php?t=25654)

Des12 03-17-2006 23:09

Modifying Entities
 
Code:
new ent[33] = 0; // . . . public makeEnt(id) {     ent[id] = create_entity("info_target");         set_task(3.0,"delEnt",id);         return PLUGIN_HANDLED; } public delEnt(id) {         new entid = ent[id]; // Error here (index out of bounds)         remove_entitiy(entid);           return PLUGIN_HANDLED; }

I just cannot figure this out...Because entid and ent[id] should both be able to store a number. The index out of bounds error is most likely being cause by the ent[id], I cannot explain why.[/small]

VEN 03-18-2006 02:37

I doubt if you can initialize arrays like that:
Code:
new ent[33] = 0
Try
Code:
new ent[33] = {0, ...}
or
Code:
new ent[33]
If that wouldn't help show the whole code.

Freecode 03-18-2006 03:00

you can.
Index out of bounds means that if you have an array ent[33] and you do ent[35] then your reaching out of bounds. So check your id's to make sure there <33

Twilight Suzuka 03-18-2006 03:54

ENT id's are 1 - 1100
player idea's are 1 - 32

Des12 03-18-2006 10:58

I still dont understand,

lets say the ent is 555, and id is 7

id = 7
ent[7] = 555
ent = 555

I don't see a problem

Twilight Suzuka 03-18-2006 11:04

Check to see if id is something higher than 32.

Ingram 03-18-2006 15:13

Code:

set_task(3.0,"delEnt",id)
wouldn't that set the # of the task, not pass id?

Des12 03-18-2006 15:33

that has worked for me countless other times unless I am doing something wrong...

and I printed out the ID in the delEnt function..it turns out be some crazy number like 34550 or something..

Des12 03-18-2006 17:22

Ok, I have solved this by putting ID in an array. But what does he mean by setting task id?

Freecode 03-18-2006 17:56

theres no problem with setting the task id same as user id, because the function that you are calling will have the task id as its argument. So your good there. But like me and Suzuka said, you were inserting something higher > 32 into your array.


All times are GMT -4. The time now is 16:36.

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