SA-MP Forums Archive
Only last teleport is working. - 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: Only last teleport is working. (/showthread.php?tid=550451)



Only last teleport is working. - Lirbo - 12.12.2014

If i'll create another one the prev one won't work, why?

pawn Код:
enum
e_TPInfo
{
Float:StartX,
Float:StartY,
Float:StartZ,
Float:EndX,
Float:EndY,
Float:EndZ
};
new TPInfo[MAX_TELEPORTS][e_TPInfo], tpid;
pawn Код:
CMD:createtp(playerid,params[]){
GetPlayerPos(playerid,pX,pY,pZ);
format(String,sizeof(String),"Teleport %i",DOF2_GetInt(TeleCount(playerid),"Count"));
Create3DTextLabel(String, -1, pX, pY, pZ, 10, 0, 0);
format(String,sizeof(String),"%i",DOF2_GetInt(TeleCount(playerid),"Count"));
DOF2_CreateFile(TeleFile(playerid));
DOF2_SetFloat(TeleFile(playerid),"StartX",TPInfo[tpid][StartX] = pX);
DOF2_SetFloat(TeleFile(playerid),"StartY",TPInfo[tpid][StartY] = pY);
DOF2_SetFloat(TeleFile(playerid),"StartX",TPInfo[tpid][StartZ] = pZ);
return 1;}

CMD:endtp(playerid,params[]){
GetPlayerPos(playerid,pX,pY,pZ);
format(String,sizeof(String),"Teleport %i",DOF2_GetInt(TeleCount(playerid),"Count"));
Create3DTextLabel(String, -1, pX, pY, pZ, 10, 0, 0);
DOF2_SetFloat(TeleFile(playerid),"EndX",TPInfo[tpid][EndX] = pX);
DOF2_SetFloat(TeleFile(playerid),"EndY",TPInfo[tpid][EndY] = pY);
DOF2_SetFloat(TeleFile(playerid),"EndX",TPInfo[tpid][EndZ] = pZ);
DOF2_SetInt(TeleCount(playerid),"Count",DOF2_GetInt(TeleCount(playerid),"Count")+1);
return 1;}

CMD:usetp(playerid,params[]){
if(IsPlayerInRangeOfPoint(playerid,2,TPInfo[tpid][StartX],TPInfo[tpid][StartY],TPInfo[tpid][StartZ])) return SetPlayerPos(playerid,TPInfo[tpid][EndX],TPInfo[tpid][EndY],TPInfo[tpid][EndZ]);
if(IsPlayerInRangeOfPoint(playerid,2,TPInfo[tpid][EndX],TPInfo[tpid][EndY],TPInfo[tpid][EndZ])) return SetPlayerPos(playerid,TPInfo[tpid][StartX],TPInfo[tpid][StartY],TPInfo[tpid][StartZ]);
return 1;}
pawn Код:
stock GetpName(playerid){
new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,sizeof(pName));
return pName;}

stock TeleCount(playerid){
GetPlayerScore(playerid);
format(String,sizeof(String),"Teleports/Count.ini");
return String;}

stock TeleFile(playerid){
GetPlayerScore(playerid);
format(String,sizeof(String),"Teleports/%i.ini",DOF2_GetInt(TeleCount(playerid),"Count"));
return String;}



Re: Only last teleport is working. - Mic_H - 12.12.2014

PHP код:
enum
e_TPInfo
{
Float:StartX,
Float:StartY,
Float:StartZ,
Float:EndX,
Float:EndY,
Float:EndZ,
tpid//Put this here.
};
new 
TPInfo[MAX_TELEPORTS][e_TPInfo];//, tpid;You are storing only one of the IDs? 



Re: Only last teleport is working. - Lirbo - 12.12.2014

Quote:
Originally Posted by Mic_H
Посмотреть сообщение
PHP код:
enum
e_TPInfo
{
Float:StartX,
Float:StartY,
Float:StartZ,
Float:EndX,
Float:EndY,
Float:EndZ,
tpid//Put this here.
};
new 
TPInfo[MAX_TELEPORTS][e_TPInfo];//, tpid;You are storing only one of the IDs? 
Ye only for IDs... TeleportID
its shows LOTS of errors:...

C:\Users\Lirbo\Desktop\Roleplay\gamemodes\ERP.pwn( 33) : error 001: expected token: "}", but found "-identifier-"
C:\Users\Lirbo\Desktop\Roleplay\gamemodes\ERP.pwn( 54) : error 017: undefined symbol "tpid"
C:\Users\Lirbo\Desktop\Roleplay\gamemodes\ERP.pwn( 55) : error 017: undefined symbol "tpid"
C:\Users\Lirbo\Desktop\Roleplay\gamemodes\ERP.pwn( 56) : error 017: undefined symbol "tpid"
C:\Users\Lirbo\Desktop\Roleplay\gamemodes\ERP.pwn( 63) : error 017: undefined symbol "tpid"
C:\Users\Lirbo\Desktop\Roleplay\gamemodes\ERP.pwn( 64) : error 017: undefined symbol "tpid"
C:\Users\Lirbo\Desktop\Roleplay\gamemodes\ERP.pwn( 65) : error 017: undefined symbol "tpid"
C:\Users\Lirbo\Desktop\Roleplay\gamemodes\ERP.pwn( 70) : error 017: undefined symbol "tpid"
C:\Users\Lirbo\Desktop\Roleplay\gamemodes\ERP.pwn( 70) : error 017: undefined symbol "tpid"
C:\Users\Lirbo\Desktop\Roleplay\gamemodes\ERP.pwn( 71) : error 017: undefined symbol "tpid"
C:\Users\Lirbo\Desktop\Roleplay\gamemodes\ERP.pwn( 71) : error 017: undefined symbol "tpid"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


Re: Only last teleport is working. - Lirbo - 13.12.2014

bump


Re: Only last teleport is working. - Dziugsas - 13.12.2014

EDIT: are you sure you putted tpid in the enum?


Re: Only last teleport is working. - Lirbo - 13.12.2014

Quote:
Originally Posted by Dziugsas
Посмотреть сообщение
EDIT: are you sure you putted tpid in the enum?
Man read my last message, I said i putted it outside, and if i put it inside so some errors appear...


Re: Only last teleport is working. - Lirbo - 13.12.2014

bump


Re: Only last teleport is working. - Mic_H - 16.12.2014

You are not doing it right..
You are saving variables for Only ONE tp..
Especially the /usetp command.. It will only work for one variable, i.e., tpid = 0..
You are not increasing tpid after /createtp.. So script will keep overwriting 0 to specified..