[Ajuda] Carregar posiзхes de jogado com a include "File"
#1

Queria uma ajuda para carregar posiзхes randфmicas de usando somente a #include <file.inc>

Isso foi o mais longe que consegui.

Код HTML:
new Float:rX[10],Float:rY[10],Float:rZ[10],Float:rR[10];
CMD:load(playerid,params[])
{
     new File:pos = fopen("positions.txt", io_read);
     new str[200];

     while(fread(pos,str))
     {
            sscanf(str,"f",rX,rY,rZ,rR);
            format(str,200,"%dX_%f,%dY_%f,%dZ_%f,%dR_%f",rX,rY,rZ,rR);
            fwrite(pos,str);
            rX = rX;
            rY = rY;
            rZ = rZ;
            rR = rR;

            SendClientMessage(playerid,-1,str);
     }
     fclose(pos);
     return 1;
}
Reply
#2

Como vocк vai fazer posiзхes randфmicas sem o random?
Reply
#3

Quote:
Originally Posted by ipsLuan
Посмотреть сообщение
Como vocк vai fazer posiзхes randфmicas sem o random?
armazenado nas variaveis
Reply
#4

ele nao esta carregando ?, como vc esta salvando essas posiзoes no txt ?
Reply
#5

Quote:
Originally Posted by ipsLuan
Посмотреть сообщение
Como vocк vai fazer posiзхes randфmicas sem o random?
na vdd ele nao quer fazer posiзoes randomicas ele so quer carregar as posiзoes que foram salvas , mas carregando do as de um modo aleatorio se foi oque eu entendi '-'
Reply
#6

Quote:
Originally Posted by LiiPe
Посмотреть сообщение
ele nao esta carregando ?, como vc esta salvando essas posiзoes no txt ?
Dessa forma e salva
Код HTML:
CMD:sav(playerid,params[])
{
    new p;
    new str[100],Float:X,Float:Y,Float:Z,Float:Rotation;
    GetPlayerPos(playerid, X, Y, Z);
    GetPlayerFacingAngle(playerid, Rotation);
    new File:pos = fopen("positions.txt", io_append);
    if(!sscanf(params,"i",p))
    {
        format(str, 100, "%dX_%f,%dY_%f,%dZ_%f,%dR_%f\r\n", p,X,p,Y,p,Z,p,Rotation);
        fwrite(pos, str);
    }
    fclose(pos);
    return 1;
}
Reply
#7

@edit nao compreendi muito bem essa include '-'

mas acho que isso possa te ajudar

https://sampwiki.blast.hk/wiki/File_Functions
Reply
#8

Tente

PHP код:
CMD:sav(playerid,params[])
{
    new 
str[100],Float:X,Float:Y,Float:Z,Float:Rotation;
    
GetPlayerPos(playerid,X,Y,Z);
    
GetPlayerFacingAngle(playerid,Rotation);
    new 
File:file;
    while(
100)
    {
        
format(str,100,"X_%f,Y_%f,Z_%f,R_%f\r\n",X,Y,Z,Rotation);
        if(
== 0)
        {
            
file fopen("positions.txt",io_write);
        }
        else
        {
            
file fopen("positions.txt",io_append);
        }
        
fwrite(pos,string);
        
fclose(pos);
        
p++;
    }
    return 
1;
}
new 
Float:rX[10],Float:rY[10],Float:rZ[10],Float:rR[10];
CMD:load(playerid,params[])
{
    new 
pos[4];
    new 
string[512];
    new 
Filefile fopen("positions.txt",io_read);
    if(
file)
    {
        new 
0;
        while(
100)
        {
            
fread(file,string);
            
split(string,pos,'|');
            
rX floatstr(pos[0]);
            
rY floatstr(pos[1]);
            
rZ floatstr(pos[2]);
            
rR floatstr(pos[3]);
            
p++;
        }
    }
    return 
1;
}
stock split(const strsrc[],strdest[][],delimiter)
{
    new 
i,li;
    new 
aNum;
    new 
len;
    while(
<= strlen(strsrc))
    {
        if(
strsrc[i] == delimiter || == strlen(strsrc))
        {
            
len strmid(strdest[aNum],strsrc,li,i,128);
            
strdest[aNum][len] = 0;
            
li i+1;
            
aNum++;
        }
        
i++;
    }
    return 
1;

Reply
#9

Quote:
Originally Posted by 1sbedx
Посмотреть сообщение
Tente

PHP код:
CMD:sav(playerid,params[])
{
    new 
str[100],Float:X,Float:Y,Float:Z,Float:Rotation;
    
GetPlayerPos(playerid,X,Y,Z);
    
GetPlayerFacingAngle(playerid,Rotation);
    new 
File:file;
    while(
100)
    {
        
format(str,100,"X_%f,Y_%f,Z_%f,R_%f\r\n",X,Y,Z,Rotation);
        if(
== 0)
        {
            
file fopen("positions.txt",io_write);
        }
        else
        {
            
file fopen("positions.txt",io_append);
        }
        
fwrite(pos,string);
        
fclose(pos);
        
p++;
    }
    return 
1;
}
new 
Float:rX[10],Float:rY[10],Float:rZ[10],Float:rR[10];
CMD:load(playerid,params[])
{
    new 
pos[4];
    new 
string[512];
    new 
Filefile fopen("positions.txt",io_read);
    if(
file)
    {
        new 
0;
        while(
100)
        {
            
fread(file,string);
            
split(string,pos,'|');
            
rX floatstr(pos[0]);
            
rY floatstr(pos[1]);
            
rZ floatstr(pos[2]);
            
rR floatstr(pos[3]);
            
p++;
        }
    }
    return 
1;
}
stock split(const strsrc[],strdest[][],delimiter)
{
    new 
i,li;
    new 
aNum;
    new 
len;
    while(
<= strlen(strsrc))
    {
        if(
strsrc[i] == delimiter || == strlen(strsrc))
        {
            
len strmid(strdest[aNum],strsrc,li,i,128);
            
strdest[aNum][len] = 0;
            
li i+1;
            
aNum++;
        }
        
i++;
    }
    return 
1;

Apareceu esses erros
Код:
C:\Users\Marlon\Desktop\NEW_GM\gamemodes\BCL_mysql.pwn(986) : error: 048: array dimensions do not match
C:\Users\Marlon\Desktop\NEW_GM\gamemodes\BCL_mysql.pwn(986) : error: 033: array must be indexed (variable "rX")
C:\Users\Marlon\Desktop\NEW_GM\gamemodes\BCL_mysql.pwn(986) : error: 033: array must be indexed (variable "rY")
C:\Users\Marlon\Desktop\NEW_GM\gamemodes\BCL_mysql.pwn(986) : error: 033: array must be indexed (variable "rZ")
C:\Users\Marlon\Desktop\NEW_GM\gamemodes\BCL_mysql.pwn(986) : error: 033: array must be indexed (variable "rR")
Reply
#10

Quote:
Originally Posted by Marlon307
Посмотреть сообщение
Apareceu esses erros
Код:
C:\Users\Marlon\Desktop\NEW_GM\gamemodes\BCL_mysql.pwn(986) : error: 048: array dimensions do not match
C:\Users\Marlon\Desktop\NEW_GM\gamemodes\BCL_mysql.pwn(986) : error: 033: array must be indexed (variable "rX")
C:\Users\Marlon\Desktop\NEW_GM\gamemodes\BCL_mysql.pwn(986) : error: 033: array must be indexed (variable "rY")
C:\Users\Marlon\Desktop\NEW_GM\gamemodes\BCL_mysql.pwn(986) : error: 033: array must be indexed (variable "rZ")
C:\Users\Marlon\Desktop\NEW_GM\gamemodes\BCL_mysql.pwn(986) : error: 033: array must be indexed (variable "rR")
PHP код:
CMD:sav(playerid,params[]) 

    new 
str[100],Float:X,Float:Y,Float:Z,Float:Rotation
    
GetPlayerPos(playerid,X,Y,Z); 
    
GetPlayerFacingAngle(playerid,Rotation); 
    new 
File:file
    while(
100
    { 
        
format(str,100,"X_%f,Y_%f,Z_%f,R_%f\r\n",X,Y,Z,Rotation); 
        if(
== 0
        { 
            
file fopen("positions.txt",io_write); 
        } 
        else 
        { 
            
file fopen("positions.txt",io_append); 
        } 
        
fwrite(pos,string); 
        
fclose(pos); 
        
p++; 
    } 
    return 
1

new 
Float:rX[10],Float:rY[10],Float:rZ[10],Float:rR[10]; 
CMD:load(playerid,params[]) 

    new 
pos[4]; 
    new 
string[512]; 
    new 
Filefile fopen("positions.txt",io_read); 
    if(
file
    { 
        new 
0
        while(
100
        { 
            
fread(file,string); 
            
split(string,pos,'|'); 
            
rX[p] = floatstr(pos[0]); 
            
rY[p] = floatstr(pos[1]); 
            
rZ[p] = floatstr(pos[2]); 
            
rR[p] = floatstr(pos[3]); 
            
p++; 
        } 
    } 
    return 
1

stock split(const strsrc[],strdest[][],delimiter

    new 
i,li
    new 
aNum
    new 
len
    while(
<= strlen(strsrc)) 
    { 
        if(
strsrc[i] == delimiter || == strlen(strsrc)) 
        { 
            
len strmid(strdest[aNum],strsrc,li,i,128); 
            
strdest[aNum][len] = 0
            
li i+1
            
aNum++; 
        } 
        
i++; 
    } 
    return 
1

Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)