Saving to .txt file -
willsuckformoney - 24.10.2010
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?
Re: Saving to .txt file -
LarzI - 24.10.2010
Why the hell do you use strtok? O_O
pawn Код:
dcmd_cp(playerid,params[])
{
if(IsPlayerAdmin(playerid)) {
new cpName;
new Float:X,Float:Y,Float:Z,string[128];
GetPlayerPos(playerid,X,Y,Z);
if(strlen(params)) {
strmid(cpName, params, 0, 255);
CreateDynamicCP(X,Y,Z,3,-1,-1,-1,100.0);
format(string,sizeof(string),"%s = CreateDynamicCP(%0.1f,%0.1f,%0.1f,3,-1,-1,-1,100.0);",cpName,X,Y,Z);
SaveToFile("CheckPoints",string);
} else return SendClientMessage(playerid,red,"USAGE: /CP [CP Name]");
} else return SendERROR(playerid,1);
return 1;
}
Re: Saving to .txt file -
willsuckformoney - 29.10.2010
Nevermind, fixed.
Re: Saving to .txt file -
HydraX - 14.11.2010
Quote:
Originally Posted by ******
O_O
|
You don't see that everyday..