SA-MP Forums Archive
File Problem (stock) - 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: File Problem (stock) (/showthread.php?tid=354883)



File Problem (stock) - calin1996 - 28.06.2012

Function:
pawn Код:
stock LoadAttachment(playerid)
{
    new str[50];
    GetPlayerName(playerid,str,50);
    format(str,50,"attachment/%s.ini",str);
    new File:f =fopen(str,io_read);
    new string[256+1];
    fread(string,256);
    new tmp[12][128];
    split(string, tmp, ',');
    new index, modelid, boneid,
       Float:fOffsetX, Float:fOffsetY, Float:fOffsetZ,
       Float:fRotX, Float:fRotY, Float:fRotZ,
       Float:fScaleX, Float:fScaleY, Float:fScaleZ;
    index = strval(tmp[0]);
    modelid = strval(tmp[1]);
    boneid = strval(tmp[2]);

    fOffsetX = floatstr(tmp[3]);
    fOffsetY = floatstr(tmp[4]);
    fOffsetZ = floatstr(tmp[5]);

    fRotX = floatstr(tmp[6]);
    fRotY = floatstr(tmp[7]);
    fRotZ = floatstr(tmp[8]);

    fScaleX = floatstr(tmp[9]);
    fScaleY = floatstr(tmp[10]);
    fScaleZ = floatstr(tmp[11]);

    SetPlayerAttachedObject(playerid,index,modelid,boneid,fOffsetX,fOffsetY,fOffsetZ,fRotX,fRotY,fRotZ,fScaleX,fScaleY,fScaleZ);
    SendClientMessage(playerid, 0xFFFFFFFF, "Your Saved Attachement Loaded!");
    return 1;
}
Errors:
pawn Код:
D:\Lucru\1.3 samp 0.3e\gamemodes\MAPA PALAMINO.pwn(397) : error 035: argument type mismatch (argument 1)
D:\Lucru\1.3 samp 0.3e\gamemodes\MAPA PALAMINO.pwn(395) : warning 204: symbol is assigned a value that is never used: "f"
Lines:
pawn Код:
397:    fread(string,256);
395:    new File:f =fopen(str,io_read);



Re: File Problem (stock) - JaTochNietDan - 28.06.2012

You are not making use of fread correctly, please see the documentation on it for an example on how to use it correctly.

https://sampwiki.blast.hk/wiki/Fread


Re: File Problem (stock) - calin1996 - 28.06.2012

IDk how to repair it,someone?


Re: File Problem (stock) - JaTochNietDan - 28.06.2012

Quote:
Originally Posted by calin1996
Посмотреть сообщение
IDk how to repair it,someone?
It expects the file handle as the first argument and the string to store the result in as the second argument, in your case:

pawn Код:
fread(f, string);
Hope that helps!


Re: File Problem (stock) - calin1996 - 28.06.2012

pawn Код:
D:\Lucru\1.3 samp 0.3e\gamemodes\MAPA PALAMINO.pwn(397) : error 035: argument type mismatch (argument 2)
pawn Код:
397:    fread(f,256);



Re: File Problem (stock) - calin1996 - 28.06.2012

How to make it? i've tried with:
fread(f,256);
and
fread(string,256);
But nothing



Re: File Problem (stock) - cessil - 28.06.2012

why are you using 256 as the second parameter when you were told to use a string variable?


Re: File Problem (stock) - calin1996 - 28.06.2012

Quote:
Originally Posted by cessil
Посмотреть сообщение
why are you using 256 as the second parameter when you were told to use a string variable?
THANK YOU