problem teleport to a position reading from file with io_read
#8

pawn Код:
if(!strcmp(cmdtext,"/gopos",true))
{
    if(fexist("mypos.txt"))
    {
        new File:IFile = fopen("mypos.txt",io_read),str[128];

        while(fread(IFile,str))
        {
            if(str[0] == '#') continue;

            new Float:X = floatstr(str);
           
            new pos = chrfind(',',str)+1;
            if(pos == 0) print("Missing 2nd parameter");
            new Float:Y = floatstr(str[pos])
           
            pos = chrfind(',',str,pos)+1;
            if(pos == 0) print("Missing 3rd parameter");
            new Float:Z = floatstr(str[pos]);
           
            printf("SetPlayerPos(playerid,%f,%f,%f)",X,Y,Z);
            SetPlayerPos(playerid,X,Y,Z);
        }
        fclose(IFile);
    }
    return 1;
}

stock chrfind(n,h[],s=0)
{
    new l = strlen(h);
    while(s < l)
    {
        if(h[s] == n) return s;
        s++;
    }
    return -1;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)