AddSaleSign(signmodel,saleid, Float:entX, Float:entY, Float:entZ, Float:entA,Price )
{
new File:pr_file,prstr[130];
signs[saleid][sex] = entX;
signs[saleid][sey] = entY;
signs[saleid][sez] = entZ;
signs[saleid][sea] = entA;
signs[saleid][cost] = Price;
pr_file = fopen( propFile[5], io_append );
if(pr_file)SignObject[saleid] = saleid;
{
format( prstr, 130, "%d,%d,%f, %f, %f, %f, %d ;// %s\r\n",signmodel,saleid,entX,entY,entZ,entA,Price);
fwrite( pr_file, prstr );
fclose( pr_file );
printf( "PropDB - %s", prstr );
signs[saleid][sid]= CreateDynamicObject(19470,entX,entY,entZ,0.000000,0.000000,entA,0,-1,-1,50);
Create3DTextLabel(Price,0xEEEE88FF,entX,entY,entZ+0.75,20.0,0,1);
}
return -1;
}
19470,0,2268.674560, 35.834636, 26.484375, 178.891632, 50000 ;// 19470,2,2245.197753, 34.113197, 26.484375, 180.142669, 50000 ;//
COMMAND:setprice(playerid, params[]) {
new signID, price;
if(sscanf(params, "ui", signID, price))
return SendClientMessage(playerid, -1, "USAGE: /setprice [houseid] [price]");
// Maybe do a check to see if sign exists
if ( !SignExists(signID) )
return SendClientMessage(playerid, -1, "ERROR: Sign doesn't exist.");
signs[signID][cost] = price;
return 1;
}
|
No this is not what i am trying to ask. I dont need a command i need to know how i can reset
the last value in a specific line in a FILE that is created in the scriptfiles folder. I am asking because i am not sure if its possible with these filefunctions. |
public fcreate(filename[])
{
if (fexist(filename)){return false;}
new File:fhandle = fopen(filename,io_write);
fclose(fhandle);
return true;
}
fdeleteline(filename[], line[]){
if(fexist(filename)){
new temp[256];
new File:fhandle = fopen(filename,io_read);
fread(fhandle,temp,sizeof(temp),false);
if(strfind(temp,line,true)==-1){return 0;}
else{
fclose(fhandle);
fremove(filename);
for(new i=0;i<strlen(temp);i++){
new templine[256];
strmid(templine,temp,i,i+strlen(line));
if(equal(templine,line,true)){
strdel(temp,i,i+strlen(line));
fcreate(filename);
fhandle = fopen(filename,io_write);
fwrite(fhandle,temp);
fclose(fhandle);
return 1;
}
}
}
}
return 0;
}
COMMAND:setprice(playerid, params[]) {
new signID, price;
if(sscanf(params, "ui", signID, price))
return SendClientMessage(playerid, -1, "USAGE: /setprice [houseid] [price]");
new File:pFile = fopen( propFile[5], io_append );
if(!pFile)
{
fcreate(propFile[5]);
}
new string[128], strFile[128];
// Your gonna have to change some shit here -
format(string, sizeof(string), "%d,%d,%f, %f, %f, %f, %d", get all the stuff with signs[signID] <--- );
while(fread(pFile, strFile)) { // Read the entire file
if ( !strcmp(string, strFile))
{
// Delete the line
fdeleteline(propFile[5], string);
format(string, sizeof(string), "%d,%d,%f, %f, %f, %f, %d", ...last Param will be -> Price );
fwrite(pFile, string);
}
}
fclose(pFile);
return 1;
}
|
made it in a couple minutes and got 2 functions from
https://sampwiki.blast.hk/wiki/ credits to Sacky for create and delete i dont code in pawno so I cant assure you it will work, you're gonna have to change some stuff Код:
public fcreate(filename[])
{
if (fexist(filename)){return false;}
new File:fhandle = fopen(filename,io_write);
fclose(fhandle);
return true;
}
fdeleteline(filename[], line[]){
if(fexist(filename)){
new temp[256];
new File:fhandle = fopen(filename,io_read);
fread(fhandle,temp,sizeof(temp),false);
if(strfind(temp,line,true)==-1){return 0;}
else{
fclose(fhandle);
fremove(filename);
for(new i=0;i<strlen(temp);i++){
new templine[256];
strmid(templine,temp,i,i+strlen(line));
if(equal(templine,line,true)){
strdel(temp,i,i+strlen(line));
fcreate(filename);
fhandle = fopen(filename,io_write);
fwrite(fhandle,temp);
fclose(fhandle);
return 1;
}
}
}
}
return 0;
}
COMMAND:setprice(playerid, params[]) {
new signID, price;
if(sscanf(params, "ui", signID, price))
return SendClientMessage(playerid, -1, "USAGE: /setprice [houseid] [price]");
new File:pFile = fopen( propFile[5], io_append );
if(!pFile)
{
fcreate(propFile[5]);
}
new string[128], strFile[128];
// Your gonna have to change some shit here -
format(string, sizeof(string), "%d,%d,%f, %f, %f, %f, %d", get all the stuff with signs[signID] <--- );
while(fread(pFile, strFile)) { // Read the entire file
if ( !strcmp(string, strFile))
{
// Delete the line
fdeleteline(propFile[5], string);
format(string, sizeof(string), "%d,%d,%f, %f, %f, %f, %d", ...last Param will be -> Price );
fwrite(pFile, string);
}
}
fclose(pFile);
return 1;
}
|