How to load up all the teleports
#1

The teleports aren't loading only the last teleport that has been created is working. I believe its a problem of the teleport load
PHP код:
#define LoadTeleports INI_ParseFile(tpFile(), "LoadTP", .bExtra = true, .extra = i);
#define MAX_TELEPORTS 50
enum TPData
{
    
ID,
    
Float:X,
    
Float:Y,
    
Float:Z,
    
Float:ToX,
    
Float:ToY,
    
Float:ToZ,
    
Description[64],
    
VW,
    
ToVW
}
new 
tpDB[MAX_TELEPORTS][TPData];
CMD:createtp(playerid,params[]){
LoggedCMD OwnerCMD
if(sscanf(params,"iffffffiis",param[0],F[0],F[1],F[2],F[3],F[4],F[5],param[1],param[2],String2)) return MSG(playerid,C_GRAY,"Error: Usage /CreateTP [Teleport ID] [X] [Y] [Z] [To X] [To Y] [To Z] [Virtual World] [To Virtual World] [Description]");
tpDB[param[0]][ID] = param[0];
tpDB[param[0]][X] = F[0];
tpDB[param[0]][Y] = F[1];
tpDB[param[0]][Z] = F[2];
tpDB[param[0]][ToX] = F[3];
tpDB[param[0]][ToY] = F[4];
tpDB[param[0]][ToZ] = F[5];
tpDB[param[0]][VW] = param[1];
tpDB[param[0]][ToVW] = param[2];
format(tpDB[param[0]][Description],64,String2);
MSG(playerid,C_WHITE,"Teleport has created successfuly!");
format(String,sizeof(String),"Teleport (%i)\n%s",tpDB[param[0]][ID],tpDB[param[0]][Description]);
Create3DTextLabel(String0xfffffffftpDB[param[0]][X], tpDB[param[0]][Y], tpDB[param[0]][Z], 25tpDB[param[0]][VW], 0);
Create3DTextLabel(String0xfffffffftpDB[param[0]][ToX], tpDB[param[0]][ToY], tpDB[param[0]][ToZ], 25tpDB[param[0]][ToVW], 0);
SaveTPFile();
return 
1;}
function 
LoadTP(playeridname[], value[])
{
    for(new 
0MAX_TELEPORTSi++){
    
INI_Int("ID",tpDB[i][ID]);
    
INI_String("Description",tpDB[i][Description],64);
    
INI_Float("X",tpDB[i][X]);
    
INI_Float("Y",tpDB[i][Y]);
    
INI_Float("Z",tpDB[i][Z]);
    
INI_Float("ToX",tpDB[i][ToX]);
    
INI_Float("ToY",tpDB[i][ToY]);
    
INI_Float("ToZ",tpDB[i][ToZ]);
    
INI_Int("VW",tpDB[i][VW]);
    
INI_Int("ToVW",tpDB[i][ToVW]);}
return 
1;
}
public 
OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if ((
newkeys KEY_SECONDARY_ATTACK) && !(oldkeys KEY_SECONDARY_ATTACK)){
    for(new 
0MAX_TELEPORTSi++){
    new 
fkstr[128];
    
format(fkstr,sizeof(fkstr),"Teleports/Teleport (%i).ini",i);
    if(
IsPlayerInRangeOfPoint(playerid,3,tpDB[fkstr][X],tpDB[i][Y],tpDB[i][Z])){
    
SetPlayerPos(playerid,tpDB[i][ToX],tpDB[i][ToY],tpDB[i][ToZ]);
    return 
1;}
    if(
IsPlayerInRangeOfPoint(playerid,3,tpDB[i][ToX],tpDB[i][ToY],tpDB[i][ToZ])){
    
SetPlayerPos(playerid,tpDB[i][X],tpDB[i][Y],tpDB[i][Z]);
    return 
1;}}
    }
    return 
1;

Reply
#2

I can't see much. maybe try using printf(); to see what the values in param[0] for /createtp and other variable values come out as? debug the long and shitty way
Reply
#3

Quote:
Originally Posted by Mowgli
Посмотреть сообщение
I can't see much. maybe try using printf(); to see what the values in param[0] for /createtp and other variable values come out as? debug the long and shitty way
It's not about the param[0] i guess, Because it's all working until I restart the server then only the last TP is working, It's something in the load for sure bro.
Reply
#4

Bump
Reply
#5

bump.............................................. ........................
help please
Reply
#6

Where's the Save function of the tpDB?
I don't get why you need the "playerid" on this function:
Код:
function LoadTP(playerid, name[], value[])
Reply
#7

Quote:
Originally Posted by Aly
Посмотреть сообщение
Where's the Save function of the tpDB?
I don't get why you need the "playerid" on this function:
Код:
function LoadTP(playerid, name[], value[])
ahh didnt notice.. i copied it from the LoadUser shit, but its still doesnt helping me bro
Reply
#8

I asked for the Save function of the tpDB?
Reply
#9

Quote:
Originally Posted by Aly
Посмотреть сообщение
I asked for the Save function of the tpDB?
stock SaveTPFile()
{
new INI:tpfile = INI_Open(tpFile());
INI_SetTag(tpfile, "Database");
INI_WriteInt(tpfile,"ID",tpDB[param[0]][ID]);
INI_WriteString(tpfile,"Description",tpDB[param[0]][Description]);
INI_WriteFloat(tpfile,"X",tpDB[param[0]][X]);
INI_WriteFloat(tpfile,"Y",tpDB[param[0]][Y]);
INI_WriteFloat(tpfile,"Z",tpDB[param[0]][Z]);
INI_WriteFloat(tpfile,"ToX",tpDB[param[0]][ToX]);
INI_WriteFloat(tpfile,"ToY",tpDB[param[0]][ToY]);
INI_WriteFloat(tpfile,"ToZ",tpDB[param[0]][ToZ]);
INI_WriteInt(tpfile,"VW",tpDB[param[0]][VW]);
INI_WriteInt(tpfile,"ToVW",tpDB[param[0]][ToVW]);
INI_Close(tpfile);
}
Reply
#10

PHP код:
#define LoadTeleports INI_ParseFile(tpFile(), "LoadTP_Database", .bExtra = true, .extra = i); 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)