enum help.
#1

Can anyone help me with this please.

Why is it not destroying the objects...

Код:
enum RopeInfo {
	RopeID,
	Float: RRX,
	Float: RRY,
	Float: RRZ,
};
new RopeInformation[MAX_PLAYERS][RopeInfo];

#define MAX_Reppel_Ropes 2500

new RopeObjects[MAX_Reppel_Ropes][RopeInfo];
YCMD:climbrope(playerid, params[], help) {
	RopeInformation[playerid][RopeID]  = CreateDynamicObject(19089, RopeInformation[playerid][RRX], RopeInformation[playerid][RRY], RopeInformation[playerid][RRZ]+5, 0, 0, Angle);
	RopeInformation[playerid][RopeID]  = CreateDynamicObject(19089, RopeInformation[playerid][RRX], RopeInformation[playerid][RRY], RopeInformation[playerid][RRZ]+3, 0, 0, Angle);
	RopeInformation[playerid][RopeID]  = CreateDynamicObject(19089, RopeInformation[playerid][RRX], RopeInformation[playerid][RRY], RopeInformation[playerid][RRZ]+2, 0, 0, Angle);
	RopeInformation[playerid][RopeID]  = CreateDynamicObject(19089, RopeInformation[playerid][RRX], RopeInformation[playerid][RRY], RopeInformation[playerid][RRZ]+1, 0, 0, Angle);
	RopeInformation[playerid][RopeID]  = CreateDynamicObject(19089, RopeInformation[playerid][RRX], RopeInformation[playerid][RRY], RopeInformation[playerid][RRZ]-5, 0, 0, Angle);
SetTimerEx("destroyrope",9000, false,"d",playerid);
}
forward destroyrope(playerid);
public destroyrope(playerid) {

	for(new i=0;i<sizeof(RopeObjects);i++ ) {
		if(RopeObjects[i][RopeID] != 0) {
			DestroyDynamicObject(RopeObjects[i][RopeID]);
			DestroyDynamicObject(RopeInformation[playerid][RopeID]);
		}
	}	
	return 1;
}





HOW COME It wont destroy the ROPES Spawned for that player?
IT doesn't destroy anything
Where have I gone wrong?


I go ingame...
IT creates the objects..

But...
After 9 seconds
IT doesnt destroy..
Reply
#2

You are only saving 1 objectid and deleting 1 objectid you lose the reference to those objects.
Reply
#3

Quote:
Originally Posted by Pottus
Посмотреть сообщение
You are only saving 1 objectid
Yea...
The ROPE = the same ID
But
I'm trying to store the RopeID

Example

If 10 ropes are spawned

RopeID would go
1
2
3
4
5
6
7
8
9
10

for that playerid
Reply
#4

Код:
enum RopeInfo {
	Float: RRX,
	Float: RRY,
	Float: RRZ,
};

new RopeInformation[MAX_PLAYERS][RopeInfo];

YCMD:climbrope(playerid, params[], help) {
	SetTimerEx("destroyrope",9000, false,"ddddd",
		CreateDynamicObject(19089, RopeInformation[playerid][RRX], RopeInformation[playerid][RRY], RopeInformation[playerid][RRZ]+5, 0, 0, Angle),
		CreateDynamicObject(19089, RopeInformation[playerid][RRX], RopeInformation[playerid][RRY], RopeInformation[playerid][RRZ]+3, 0, 0, Angle),
		CreateDynamicObject(19089, RopeInformation[playerid][RRX], RopeInformation[playerid][RRY], RopeInformation[playerid][RRZ]+2, 0, 0, Angle),
		CreateDynamicObject(19089, RopeInformation[playerid][RRX], RopeInformation[playerid][RRY], RopeInformation[playerid][RRZ]+1, 0, 0, Angle),
		CreateDynamicObject(19089, RopeInformation[playerid][RRX], RopeInformation[playerid][RRY], RopeInformation[playerid][RRZ]-5, 0, 0, Angle)
	);
}

forward destroyrope(obj1,obj2,obj3,obj4,obj5);
public destroyrope(obj1,obj2,obj3,obj4,obj5) {
	DestroyDynamicObject(obj1);
	DestroyDynamicObject(obj2);
	DestroyDynamicObject(obj3);
	DestroyDynamicObject(obj4);
	DestroyDynamicObject(obj5);
}
Reply
#5

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Код:
enum RopeInfo {
	Float: RRX,
	Float: RRY,
	Float: RRZ,
};

new RopeInformation[MAX_PLAYERS][RopeInfo];

YCMD:climbrope(playerid, params[], help) {
	SetTimerEx("destroyrope",9000, false,"ddddd",
		CreateDynamicObject(19089, RopeInformation[playerid][RRX], RopeInformation[playerid][RRY], RopeInformation[playerid][RRZ]+5, 0, 0, Angle),
		CreateDynamicObject(19089, RopeInformation[playerid][RRX], RopeInformation[playerid][RRY], RopeInformation[playerid][RRZ]+3, 0, 0, Angle),
		CreateDynamicObject(19089, RopeInformation[playerid][RRX], RopeInformation[playerid][RRY], RopeInformation[playerid][RRZ]+2, 0, 0, Angle),
		CreateDynamicObject(19089, RopeInformation[playerid][RRX], RopeInformation[playerid][RRY], RopeInformation[playerid][RRZ]+1, 0, 0, Angle),
		CreateDynamicObject(19089, RopeInformation[playerid][RRX], RopeInformation[playerid][RRY], RopeInformation[playerid][RRZ]-5, 0, 0, Angle)
	);
}

forward destroyrope(obj1,obj2,obj3,obj4,obj5);
public destroyrope(obj1,obj2,obj3,obj4,obj5) {
	DestroyDynamicObject(obj1);
	DestroyDynamicObject(obj2);
	DestroyDynamicObject(obj3);
	DestroyDynamicObject(obj4);
	DestroyDynamicObject(obj5);
}

This wont work,
If 2 people use this command at the same time
It will only destroy the 2nd persons objects...
hence why I need to save it in the enum
Reply
#6

It passes the objectid's to delete.
Reply
#7

Quote:
Originally Posted by Pottus
Посмотреть сообщение
It passes the objectid's to delete.

yea
But...
There's 70Objects
It spawns ropes in a line till they hit the floor
Reply
#8

Bump
Reply
#9

Oh alright I see you have an indeterminate number of ropes which means you need some kind of control system to handle clean up. There is a few things you will need to consider.

1.) Can a player spawn multiple sets of ropes at one time?
2.) Maximum rope length?

Actually storing/deleting the objectids is really easy so I mean the main issue is the way you designed it it only creates 5 ropes so that code was insufficient to do anything more than what was done.
Reply
#10

Quote:
Originally Posted by Pottus
Посмотреть сообщение
Oh alright I see you have an indeterminate number of ropes which means you need some kind of control system to handle clean up. There is a few things you will need to consider.

1.) Can a player spawn multiple sets of ropes at one time?
2.) Maximum rope length?

Actually storing/deleting the objectids is really easy so I mean the main issue is the way you designed it it only creates 5 ropes so that code was insufficient to do anything more than what was done.
1.) They cannot spawn multiple, Once they use the command a timer is set.
2.) Maximum length is 71.

I didn't design it to store 5, The way I did it was it inserts each object created into the enum field.
But I obviously did it wrong because it dont work lol.


I'll post the full code below
Reply


Forum Jump:


Users browsing this thread: 9 Guest(s)