Don't Work Program...
#1

Sorry Bad English....
Teleport Script is a being created
Does not work properly
What is the name of your command to get the coordinates from a text and teleport
I want to move the
Where How do I fix this?

///////////////////////////////////////////////////////////////////
#include <a_samp>
#include <dutils>
#pragma tabsize 0

#define MAX_LIST 2000

enum TPL
{
Float:X,
Float:Y,
Float:Z,
Interior,
NAME[256],
CMD[256]
};

new Tel[MAX_LIST][TPL];

public OnFilterScriptInit()
{
LoadFile();
return 1;
}

public OnFilterScriptExit()
{
return 1;
}

stock LoadFile()
{

//============use to local================

new File:hFile,
tmp[256],
buf[256],
idx,
Float,
Float:y,
Float:z,
interior,
cnt=0;


hFile = fopen("loadtp.ini",io_read);
if(!hFile) return printf("Not Load File");

//================MAIN===================

print("Load To file : loadtp.ini");

while(fread(hFile,buf,256) > 0) {
idx = 0;

idx = token_by_delim(buf,tmp,',',idx+1);
if(idx == (-1)) continue;
x = floatstr(tmp);

idx = token_by_delim(buf,tmp,',',idx+1);
if(idx == (-1)) continue;
y = floatstr(tmp);

idx = token_by_delim(buf,tmp,',',idx+1);
if(idx == (-1)) continue;
z = floatstr(tmp);

idx = token_by_delim(buf,tmp,',',idx+1);
if(idx == (-1)) continue;
interior = strval(tmp);

idx = token_by_delim(buf,Tel[cnt][NAME],',',idx+1);
if(idx == (-1)) continue;

idx = token_by_delim(buf,Tel[cnt][CMD],'\n',idx+1);
if(idx == (-1)) continue;

Tel[cnt][X] = x;
Tel[cnt][Y] = y;
Tel[cnt][Z] = z;
Tel[cnt][Interior] = interior;

cnt++;
}
fclose(hFile);
return 1;
}

public OnPlayerCommandText(playerid,cmdtext[])
{
new cmd[256];
new idx;

cmd = strtok(cmdtext,idx);

if(strcmp(cmd,"/tp",true) == 0){
cmd = strtok(cmdtext,idx);
new cmdname[256];
strmid(cmdname, cmd, 1, strlen(cmd));
for(new i=0;i<MAX_LIST;i++){
if(strcmp(Tel[i][CMD],cmdname,true) == 0){
if(IsPlayerInAnyVehicle(playerid)){
new vehicle = GetPlayerVehicleID(playerid);
SetVehiclePos(vehicle,Tel[i][X],Tel[i][Y],Tel[i][Z]);
LinkVehicleToInterior(vehicle,Tel[i][Interior]);
SetPlayerInterior(playerid,Tel[i][Interior]);
} else
{
SetPlayerPos(playerid,Tel[i][X],Tel[i][Y],Tel[i][Z]);
SetPlayerInterior(playerid,Tel[i][Interior]);
}
new str[256],name[256];
GetPlayerName(playerid,name,sizeof name);
format(str,sizeof str,"%s has %s to teleport(/%s)",name,Tel[i][NAME],Tel[i][CMD]);
SendClientMessage(playerid,0xFFFFFFAA,str);
} else {
SendClientMessage(playerid,0xFFFFFFAA,"No prace");
}
return 1;
}

}

return 0;
}

token_by_delim(const string[], return_str[], delim, start_index)
{
new x=0;
while(string[start_index] != EOS && string[start_index] != delim)
{
return_str[x] = string[start_index];
x++;
start_index++;
}
return_str[x] = EOS;
if(string[start_index] == EOS)
start_index = (-1);
return start_index;
}

///////////////////////////////////////////////////////////////////////////////////

The contents of this file is

2028.285400,1007.138793,10.820312,0,LosSants,lv
-2026.062255,140.259765,28.835937,0,SanFierro,sf
Reply


Messages In This Thread
Don't Work Program... - by xakey - 17.02.2011, 10:12
Re: Don't Work Program... - by AK47317 - 17.02.2011, 12:40
Re: Don't Work Program... - by xakey - 17.02.2011, 13:09
Re: Don't Work Program... - by alpha500delta - 17.02.2011, 14:16
Re: Don't Work Program... - by xakey - 17.02.2011, 15:06

Forum Jump:


Users browsing this thread: 1 Guest(s)