PDA

View Full Version : Teleporting system


1fret
15/04/2017, 12:02 AM
I once made an thread on this forums about a tp system, anyhow i tried to do it by my self which it works greate only issue is im trying to ad and 3d text to it.. But when i try to create the tp it creates the 3d text good but when i try to change the name only one 3dtext name changes and im wondering why

if(!strcmp(params, "text", true, 4))
{
if(sscanf(params, "s[128]is[128]", params, idx, text)) return SendClientMessage(playerid, error, "Usage: /dedit text [doorid] [text]");
if(DoorInfo[idx][dType] == 0) return SendClientMessage(playerid, error, "Invalid door id.");
format(DoorInfo[idx][dText], 128, "%s", text);
format(string, sizeof(string), ""COE"%s (%d)", DoorInfo[idx][dText] , idx);
UpdateDynamic3DTextLabelText(DoorInfo[idx][dTextID], -1, string);
format(DoorInfo[idx][iText], 128, "%s", text);
format(string, sizeof(string), ""COE"%s (%d)", DoorInfo[idx][iText] , idx);
UpdateDynamic3DTextLabelText(DoorInfo[idx][dTextID], -1, string);
format(string, sizeof(string), " You have set door ID %d's text to %s", idx, text);
SendClientMessage(playerid, -1, string);
}
if(!strcmp(params, "interior", true, 8))
{
if(sscanf(params, "s[128]i", params, idx, text)) return SendClientMessage(playerid, error, "Usage: /dedit interior [doorid]");
if(DoorInfo[idx][dType] == 0) return SendClientMessage(playerid, error, "Invalid door id.");
DoorInfo[idx][dIInt] = GetPlayerInterior(playerid);
DoorInfo[idx][dIVW] = GetPlayerVirtualWorld(playerid);
GetPlayerFacingAngle(playerid, DoorInfo[idx][dIA]);
GetPlayerPos(playerid, DoorInfo[idx][dIX], DoorInfo[idx][dIY], DoorInfo[idx][dIZ]);
format(string, sizeof(string), ""COE"%s (%d)", DoorInfo[idx][iText] , idx);
DoorInfo[idx][dTextID] = CreateDynamic3DTextLabel(string, -1, DoorInfo[idx][dIX], DoorInfo[idx][dIY], DoorInfo[idx][dIZ]+0.3, 15);
format(string, sizeof(string), " You have set door ID %d's interior to your coordinates. (Int: %d | VW: %d)", idx, GetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid));
SendClientMessage(playerid, -1, string);
}


Also whenever i start the local host it shows a message like this sscanf warning: Format specifier does not match parameter count. i dont know how to fix it can you help me, i will be active on forums and is awaiting any reply

DarkSkull
15/04/2017, 12:05 AM
if(sscanf(params, "s[128]i", params, idx, text)) return SendClientMessage(playerid, error, "Usage: /dedit interior [doorid]");

The sscanf error comes due to this line. You have specified two specifiers, but three parameters.

Change it to this:
this is the sscanf in the interior part of the code.
EDIT: UPDATED THE CODE TO SUPPORT 2 Parameters.
if(sscanf(params, "s[128]i", params, idx)) return SendClientMessage(playerid, error, "Usage: /dedit interior [doorid]");

As for the 3D label, I don't see you updating the 3d text label in the interior part of the code.

1fret
15/04/2017, 12:28 AM
if(sscanf(params, "s[128]i", params, idx, text)) return SendClientMessage(playerid, error, "Usage: /dedit interior [doorid]");

The sscanf error comes due to this line. You have specified two specifiers, but three parameters.

Change it to this:
this is the sscanf in the interior part of the code.
EDIT: UPDATED THE CODE TO SUPPORT 2 Parameters.
if(sscanf(params, "s[128]i", params, idx)) return SendClientMessage(playerid, error, "Usage: /dedit interior [doorid]");

As for the 3D label, I don't see you updating the 3d text label in the interior part of the code.

Ok thanks for the sscanf fix, but now let me try to explain a bit more with some diagrams....

https://s29.postimg.org/u5rk6g44j/exp1.png (https://postimg.org/image/u5rk6g44j/)
this is how it looks when i create first create the tp... the blue arrow indicates the frist created tp(exterior) and the red arrow indicates the last tp created(interior).

https://s29.postimg.org/wod974pur/exp2.png (https://postimg.org/image/wod974pur/)
Now when i try to edit the name cause i want both tps to have the same name now when i try to change the name only the last tp name changes and the first tp name doesnt update..

DarkSkull
15/04/2017, 12:38 AM
Can you show the code for exterior as well?

1fret
15/04/2017, 12:39 AM
Can you show the code for exterior as well?

if(!strcmp(params, "exterior", true, 8))
{
if(sscanf(params, "s[128]i", params, idx)) return SendClientMessage(playerid, error, "Usage: /dedit interior [doorid]");
if(DoorInfo[idx][dType] == 0) return SendClientMessage(playerid,error, "Invalid door id.");
DoorInfo[idx][dOInt] = GetPlayerInterior(playerid);
DoorInfo[idx][dOVW] = GetPlayerVirtualWorld(playerid);
GetPlayerFacingAngle(playerid, DoorInfo[idx][dOA]);
GetPlayerPos(playerid, DoorInfo[idx][dOX], DoorInfo[idx][dOY], DoorInfo[idx][dOZ]);
DestroyDynamicPickup(DoorInfo[idx][dPickup]);
DoorInfo[idx][dPickup] = CreateDynamicPickup(DoorInfo[idx][dType], 1, DoorInfo[idx][dOX], DoorInfo[idx][dOY], DoorInfo[idx][dOZ], DoorInfo[idx][dOVW], DoorInfo[idx][dOInt]);
DestroyDynamic3DTextLabel(DoorInfo[idx][dTextID]);
format(string, sizeof(string), ""COE"%s (%d)", DoorInfo[idx][dText] , idx);
DoorInfo[idx][dTextID] = CreateDynamic3DTextLabel(string, -1, DoorInfo[idx][dOX], DoorInfo[idx][dOY], DoorInfo[idx][dOZ]+0.3, 15);
format(string, sizeof(string), " You have set door ID %d's exterior to your coordinates. (Int: %d | VW: %d)", idx, GetPlayerInterior(playerid), GetPlayerVirtualWorld(playerid));
SendClientMessage(playerid, -1, string);
}

DarkSkull
15/04/2017, 12:50 AM
if(sscanf(params, "s[128]is[128]", params, idx, text)) return SendClientMessage(playerid, error, "Usage: /dedit text [doorid] [text]");

You text sscanf is also messed up. You are using three specifiers and 3 parameters, But you don't need the first string. I'm not sure if that is the problem here, But you might as well try to fix that. Here's the fix for it.

if(sscanf(params, "is[128]", idx, text)) return SendClientMessage(playerid, error, "Usage: /dedit text [doorid] [text]");

Also I've noticed something. In your interior and exterior, where you update the coordinates, You use text and idx, But you only use the id and not the text. Here are fixes for both of them as well.

if(sscanf(params, "i", idx)) return SendClientMessage(playerid, error, "Usage: /dedit interior [doorid]"); // interior
if(sscanf(params, "i", idx)) return SendClientMessage(playerid, error, "Usage: /dedit exterior [doorid]"); // exterior

Try these and check if it fixxes it

1fret
15/04/2017, 01:02 AM
if(sscanf(params, "s[128]is[128]", params, idx, text)) return SendClientMessage(playerid, error, "Usage: /dedit text [doorid] [text]");

You text sscanf is also messed up. You are using three specifiers and 3 parameters, But you don't need the first string. I'm not sure if that is the problem here, But you might as well try to fix that. Here's the fix for it.

if(sscanf(params, "is[128]", idx, text)) return SendClientMessage(playerid, error, "Usage: /dedit text [doorid] [text]");

Also I've noticed something. In your interior and exterior, where you update the coordinates, You use text and idx, But you only use the id and not the text. Here are fixes for both of them as well.

if(sscanf(params, "i", idx)) return SendClientMessage(playerid, error, "Usage: /dedit interior [doorid]"); // interior
if(sscanf(params, "i", idx)) return SendClientMessage(playerid, error, "Usage: /dedit exterior [doorid]"); // exterior

Try these and check if it fixxes it

I have fixed the sscanf error , now about the interior and exterior thing... I just want if i change tp1 name to Chicken it will update the both texts so tp2 name will also be changed to Chicken...

DarkSkull
15/04/2017, 01:22 AM
What you need to do is update both the door ids. Do you store the id of the corresponding exterior for an interior and vice versa? Can you show us your enum?

1fret
15/04/2017, 01:31 AM
RESOLVED