SA-MP Forums Archive
enum help. - 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)
+--- Thread: enum help. (/showthread.php?tid=577518)



enum help. - Prokill911 - 12.06.2015

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..


Re: enum help. - Pottus - 12.06.2015

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


Re: enum help. - Prokill911 - 12.06.2015

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


Re: enum help. - Pottus - 12.06.2015

Код:
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);
}



Re: enum help. - Prokill911 - 12.06.2015

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


Re: enum help. - Pottus - 12.06.2015

It passes the objectid's to delete.


Re: enum help. - Prokill911 - 12.06.2015

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


Re: enum help. - Prokill911 - 12.06.2015

Bump


Re: enum help. - Pottus - 12.06.2015

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.


Re: enum help. - Prokill911 - 12.06.2015

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