28.12.2013, 19:24
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...)
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)
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:
But when I rename it using /doorname it also doesn't work:
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!
Код:
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; }
Код:
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; }
Код:
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; }
Код:
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; }
Thank you for the help in advance!