SA-MP Forums Archive
Problems with Dynamic Doors - 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: Problems with Dynamic Doors (/showthread.php?tid=484019)



Problems with Dynamic Doors - KtotheYle - 28.12.2013

Hello members of GTA SAMP Forums, I have made/based off of a dynamic door system for a RP server I am making. So my friend allowed me to use his account to get help with the saving of the dynamic doors (Which that code is here...)

Код:
SaveDoors()
{
    new file[30];
    for(new i= 1; i < MAX_DOORS; i++)
    {
        if(DoorIDTaken[i] == 0) continue;
        format(file, sizeof(file), "Doors/%d.ini", i);

        new INI:FILE = INI_Open(file);
        INI_WriteInt(FILE, "PickupModel", DoorInfo[i][dPickupModel]);
        INI_WriteFloat(FILE, "EnterX", DoorInfo[i][dEnterX]);
        INI_WriteFloat(FILE, "EnterY", DoorInfo[i][dEnterY]);
        INI_WriteFloat(FILE, "EnterZ", DoorInfo[i][dEnterZ]);
        INI_WriteFloat(FILE, "ExitX", DoorInfo[i][dExitX]);
        INI_WriteFloat(FILE, "ExitY", DoorInfo[i][dExitY]);
        INI_WriteFloat(FILE, "ExitZ", DoorInfo[i][dExitZ]);
        INI_WriteInt(FILE, "Int", DoorInfo[i][dInt]);
        INI_WriteInt(FILE, "ExitVW", DoorInfo[i][dExitVW]);
        INI_WriteInt(FILE, "ExitInt", DoorInfo[i][dExitInt]);
        INI_WriteInt(FILE, "EnterVW", DoorInfo[i][dEnterVW]);
        INI_WriteInt(FILE, "EnterInt", DoorInfo[i][dEnterInt]);
        INI_WriteString(FILE, "Name", DoorInfo[i][dName]);
        INI_Close();
    }
    return 1;
}
But now I am running to a error with the loading of saved ones once I exit the script. I have tried to fix this so please excuse any errors you notice right off the bat (Code is here)

Код:
stock LoadDoors()
{
    new dStr[128];
    new file[128];
	for(new idx=1; idx<MAX_DOORS; idx++)
	{
		format(file, sizeof(file), "Doors/%d.ini", idx);
	    //if(fexist(file) && INI_Open(file))
	    //{
	   	DoorInfo[idx][dPickupModel] = INI_ReadInt("PickupModel");
	   	DoorInfo[idx][dEnterX] = INI_ReadFloat("EnterX");
	   	DoorInfo[idx][dEnterY] = INI_ReadFloat("EnterY");
	   	DoorInfo[idx][dEnterZ] = INI_ReadFloat("EnterZ");
	   	DoorInfo[idx][dExitX]  = INI_ReadFloat("ExitX");
	   	DoorInfo[idx][dExitY]  = INI_ReadFloat("ExitY");
	   	DoorInfo[idx][dExitZ]  = INI_ReadFloat("ExitZ");
	   	DoorInfo[idx][dInt] = INI_ReadInt("Int");
	   	DoorInfo[idx][dExitVW] = INI_ReadInt("ExitVW");
	   	DoorInfo[idx][dExitInt] = INI_ReadInt("ExitInt");
	    DoorInfo[idx][dEnterVW] = INI_ReadInt("EnterVW");
	   	DoorInfo[idx][dEnterInt] = INI_ReadInt("EnterInt");
	   	
		INI_ReadString(DoorInfo[idx][dName],"Name", 128);
       	format(dStr, sizeof(dStr), "[%s]\nID: %d\nPress C to enter.",DoorInfo[idx][dName], idx);

		DoorInfo[idx][dLabel] = Create3DTextLabel(dStr, COLOR_YELLOW, DoorInfo[idx][dEnterX], DoorInfo[idx][dEnterY], DoorInfo[idx][dEnterZ], 10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 100.0);
		DoorInfo[idx][dPickup] = CreatePickup(DoorInfo[idx][dPickupModel], 23, DoorInfo[idx][dEnterX], DoorInfo[idx][dEnterY], DoorInfo[idx][dEnterZ], 0, 0, -1, 70.0);
		DoorIDTaken[idx] = 1;

		INI_Close();
		//}
	}
	return 1;
}
I also am having a problem with the naming, it is set up to say : [Door name][ID] Press c to enter the door. But this does not show up, when I make the door it only shows the pickup and the name flashes, here is the createdoor command:

Код:
CMD:createdoor(playerid, params[])
{
	if(PlayerInfo[playerid][pAdminLevel] >= 4)
	{
	    new doorname[128], Float: dPos[3], string[254];
	    if(sscanf(params, "s[128]", doorname)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /createdoor [name]");

		new id = GetAvailableID();
		GetPlayerPos(playerid, dPos[0], dPos[1], dPos[2]);
		DoorIDTaken[id] = 1;
		DoorInfo[id][dEnterX] = dPos[0];
		DoorInfo[id][dEnterY] = dPos[1];
		DoorInfo[id][dEnterZ] = dPos[2];
		DoorInfo[id][dExitX] = 0.0;
		DoorInfo[id][dExitY] = 0.0;
		DoorInfo[id][dExitZ] = 0.0;
		DoorInfo[id][dInt] = 0;
		DoorInfo[id][dExitVW] = 0;
		DoorInfo[id][dExitInt] = 0;
		DoorInfo[id][dEnterVW] = GetPlayerVirtualWorld(playerid);
		DoorInfo[id][dEnterInt] = GetPlayerInterior(playerid);
		DoorInfo[id][dPickupModel] = 19130;
		DoorInfo[id][dName] = doorname;

		format(string, sizeof(string), "[%s]\nID: %d\nPress C to enter.",DoorInfo[id][dName], id);
		DoorInfo[id][dLabel] = Create3DTextLabel(string, COLOR_YELLOW, DoorInfo[id][dEnterX], DoorInfo[id][dEnterY], DoorInfo[id][dEnterZ], 10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 50.0);
		DoorInfo[id][dPickup] = CreatePickup(19130, 23, dPos[0], dPos[1], dPos[2], 0, 0, -1, 50.0);
		SaveDoors();
		return 1;
	}
	return 1;
}
But when I rename it using /doorname it also doesn't work:

Код:
CMD:doorname(playerid, params[])
{
	new string[128], id, doorname[128];
	if(PlayerInfo[playerid][pAdminLevel] >= 4)
	{
		if(sscanf(params, "ds[128]", id, doorname)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /doorname [doorid] [name]");
		if (id < 1 || id > MAX_DOORS)
		{
			format(string, sizeof(string), "ID cannot be below 1 or above %d.", MAX_DOORS);
  			SendClientMessage(playerid, COLOR_GREY, string);
    		return 1;
		}
 		if(!DoorIDTaken[id])
	 	{
   			SendClientMessage(playerid, COLOR_GREY, "ID not taken.");
			return 1;
		}

		DoorInfo[id][dName] = doorname;
		Delete3DTextLabel(DoorInfo[id][dLabel]);
		format(string, sizeof(string), "[%s]\nID: %d\nPress C to enter.",DoorInfo[id][dName], id);
		DoorInfo[id][dLabel] = Create3DTextLabel(string, COLOR_YELLOW, DoorInfo[id][dEnterX], DoorInfo[id][dEnterY], DoorInfo[id][dEnterZ], 10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 50.0);
		SaveDoors();
	}
	else
	{
		SendClientMessage(playerid,COLOR_GREY,"You are not able to use this command!");
	}
	return 1;
}
Also, no errors show up it runs with 47 warnings (Those will be fixed later) so I have no idea what is the problem.

Thank you for the help in advance!


Re: Problems with Dynamic Doors - Mattakil - 28.12.2013

Show the enum


Re: Problems with Dynamic Doors - KtotheYle - 28.12.2013

Quote:
Originally Posted by Mattakil
Посмотреть сообщение
Show the enum
These are them for the Dynamic Doors:

Код:
enum dInfo
{
	dName[128],
	dPickup,
	dPickupModel,
	Float: dEnterX,
	Float: dEnterY,
	Float: dEnterZ,
	Float: dExitX,
	Float: dExitY,
	Float: dExitZ,
	Text3D: dLabel,
	dInt,
	dExitVW,
	dExitInt,
	dEnterVW,
	dEnterInt
}



Re: Problems with Dynamic Doors - Mattakil - 28.12.2013

you have
pawn Код:
Create3DTextLabel(string, COLOR_YELLOW, DoorInfo[id][dEnterX], DoorInfo[id][dEnterY], DoorInfo[id][dEnterZ], 10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 50.0);
make it

pawn Код:
Create3DTextLabel(string, COLOR_YELLOW, DoorInfo[id][dEnterX], DoorInfo[id][dEnterY], DoorInfo[id][dEnterZ], 10.0, 0, 0, 50.0);
number of arguments does not match definition. You should read your warnings before posting for help.


Re: Problems with Dynamic Doors - KtotheYle - 29.12.2013

Quote:
Originally Posted by Mattakil
Посмотреть сообщение
you have
pawn Код:
Create3DTextLabel(string, COLOR_YELLOW, DoorInfo[id][dEnterX], DoorInfo[id][dEnterY], DoorInfo[id][dEnterZ], 10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 0, -1, -1, -1, 50.0);
make it

pawn Код:
Create3DTextLabel(string, COLOR_YELLOW, DoorInfo[id][dEnterX], DoorInfo[id][dEnterY], DoorInfo[id][dEnterZ], 10.0, 0, 0, 50.0);
number of arguments does not match definition. You should read your warnings before posting for help.
Yea should have thanks, but I'm also getting the problem with the loading of the doors which is my main thing.


Re: Problems with Dynamic Doors - J4mmyHD - 29.12.2013

pawn Код:
Where you have Doorinfo[][dName] = name;
Change it to

pawn Код:
format(DoorInfo[Id][dName], 125, "%s", name);



Re: Problems with Dynamic Doors - KtotheYle - 29.12.2013

Quote:
Originally Posted by J4mmyHD
Посмотреть сообщение
pawn Код:
Where you have Doorinfo[][dName] = name;
Change it to

pawn Код:
format(DoorInfo[Id][dName], 125, "%s", name);
Ok, I see what you are talking about and how you are telling me to replace

Код:
INI_ReadString(DoorInfo[idx][dName],"Name", 128);
With you

Код:
INI_ReadString(format(DoorInfo[Id][dName], 125, "%s", name);
I believe this to be what your are talking about, please excuse I am new to scripting pawno but this is all a very good learning experience for myself and I thank you.

But is there a place where I define name or do I replace name with something else?

I was adding that to the wrong place so I got an error. It looks like there is no error now for it, but the loading still does not work.


Re: Problems with Dynamic Doors - Crayder - 30.12.2013

This isn't really relevant with your current conversation, but I do not really like saving doors, I made myself an include before, with functions to create doors, it allows the creation of three types of doors, (sliding, teleport, and rotating). Instead of saving all you need to do is add
Quote:

CreateDoor(objectid, type of door, x, y, z, ex, ey, ez);

ex, ey, and ez being either where the player is teleported, or where the door slides to. Then if the type is rotating, ex is the starting rotation and ey is the ending rotation. Then if the door is already open, it returns to the original x y z when a player activates it again... If you would like I could find my script, and give it to you, as long as it is credited to me if you release it...


Re: Problems with Dynamic Doors - KtotheYle - 30.12.2013

Quote:
Originally Posted by Crayder
Посмотреть сообщение
This isn't really relevant with your current conversation, but I do not really like saving doors, I made myself an include before, with functions to create doors, it allows the creation of three types of doors, (sliding, teleport, and rotating). Instead of saving all you need to do is add ex, ey, and ez being either where the player is teleported, or where the door slides to. Then if the type is rotating, ex is the starting rotation and ey is the ending rotation. Then if the door is already open, it returns to the original x y z when a player activates it again... If you would like I could find my script, and give it to you, as long as it is credited to me if you release it...
Sounds cool how it is set up, so it is sorta like gates? I would love to take a look and of course you would get credit! Also is it based off a /enter system? or a command that would rotate it if put in, move or what not.

But overall if you could find it I would love to take a look and would make a command to give credits to people!


Re: Problems with Dynamic Doors - Crayder - 30.12.2013

Quote:
Originally Posted by KtotheYle
Посмотреть сообщение
Sounds cool how it is set up, so it is sorta like gates? I would love to take a look and of course you would get credit! Also is it based off a /enter system? or a command that would rotate it if put in, move or what not.

But overall if you could find it I would love to take a look and would make a command to give credits to people!
Yea, and also... It's on my laptop, in which is at my other house... And right now it's set to be controlled by keys, instead of commands... So pressing enter will control that door, instead of typing /enter... Pm me, so I don't have to track this thread...