Saving to .txt file
#1

OK I have this command here:

pawn Код:
dcmd_cp(playerid,params[])
{
    if(IsPlayerAdmin(playerid)) {
        new cpName, tmp[256], Index;
        tmp = strtok(params,Index),cpName = strval(tmp);
        new Float:X,Float:Y,Float:Z,string[128];
        GetPlayerPos(playerid,X,Y,Z);
        if(strlen(params))
        {
            CreateDynamicCP(X,Y,Z,3,-1,-1,-1,100.0);
            format(string,sizeof(string),"new %s = CreateDynamicCP(%0.1f,%0.1f,%0.1f,3,-1,-1,-1,100.0);",cpName,X,Y,Z);
            SaveToFile("CheckPoints",string);
            format(string,sizeof(string),"Dynamic CheckPoint Created! X = %0.1f, Y = %0.1f, Z = %0.1f, Name = %s",X,Y,Z,cpName);
            SendClientMessageToAll(MSGSUCC_COLOR,string);
        } else return SendClientMessage(playerid,red,"USAGE: /CP [CP Name]");
    } else return SendERROR(playerid,1);
    return 1;
}
//
forward SaveToFile(filename[],text[]);
public SaveToFile(filename[],text[])
{
    new File:FAdmin, filepath[256], string[256];

    format(filepath,sizeof(filepath),"CNR/logs/%s.txt",filename);
    FAdmin = fopen(filepath,io_append);
    format(string,sizeof(string),"%s\r\n",text);
    fwrite(FAdmin,string);
    fclose(FAdmin);

    return 1;
}
It all works but the problem is, it wont save the CP name it just saves as

= CreateDynamicCP(PX,PY,PZ,3,-1,-1,-1,100.0);

Its missing the name at the beginning. Anyone know why?
Reply


Messages In This Thread
Saving to .txt file - by willsuckformoney - 24.10.2010, 13:59
Re: Saving to .txt file - by LarzI - 24.10.2010, 14:06
Re: Saving to .txt file - by willsuckformoney - 29.10.2010, 12:09
Re: Saving to .txt file - by HydraX - 14.11.2010, 13:51

Forum Jump:


Users browsing this thread: 1 Guest(s)