Raised This Month: $ Target: $400
 0% 

Modifying Entities


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Des12
Senior Member
Join Date: Jan 2005
Old 03-17-2006 , 23:09   Modifying Entities
Reply With Quote #1

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]
__________________
-Dest Romano

www.JustRP.com
A TSRP Server

Quote:
Originally Posted by Brad
Don't you go be bringing reality into this.
Des12 is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 03-18-2006 , 02:37  
Reply With Quote #2

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.
VEN is offline
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 03-18-2006 , 03:00  
Reply With Quote #3

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
Freecode is offline
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 03-18-2006 , 03:54  
Reply With Quote #4

ENT id's are 1 - 1100
player idea's are 1 - 32
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
Des12
Senior Member
Join Date: Jan 2005
Old 03-18-2006 , 10:58  
Reply With Quote #5

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
__________________
-Dest Romano

www.JustRP.com
A TSRP Server

Quote:
Originally Posted by Brad
Don't you go be bringing reality into this.
Des12 is offline
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 03-18-2006 , 11:04  
Reply With Quote #6

Check to see if id is something higher than 32.
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
Ingram
Veteran Member
Join Date: May 2004
Old 03-18-2006 , 15:13  
Reply With Quote #7

Code:
set_task(3.0,"delEnt",id)
wouldn't that set the # of the task, not pass id?
Ingram is offline
Des12
Senior Member
Join Date: Jan 2005
Old 03-18-2006 , 15:33  
Reply With Quote #8

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..
__________________
-Dest Romano

www.JustRP.com
A TSRP Server

Quote:
Originally Posted by Brad
Don't you go be bringing reality into this.
Des12 is offline
Des12
Senior Member
Join Date: Jan 2005
Old 03-18-2006 , 17:22  
Reply With Quote #9

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

www.JustRP.com
A TSRP Server

Quote:
Originally Posted by Brad
Don't you go be bringing reality into this.
Des12 is offline
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 03-18-2006 , 17:56  
Reply With Quote #10

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.
Freecode is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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