Hello,
I've tried many times to make a non overwriting saveloc, but I failed.
Does anyone have it and/or can share with me?
I found this, but I only need the saveloc part, but when I try to compile it gives me errors...
#include <a_samp>
#include <core>
#include <float>
function8(arg0, arg1)
{
new File:var0 = 0, File:var1 = 0;
if(!fexist(arg0))
{
return 0;
}
var0 = fopen(arg0, 0);
var1 = fopen(arg1, 1);
new var2[75];
while(fread(var0, var2, 75))
{
function220(var2);
format(var2, 75, "%s\r\n", var2);
fwrite(var1, var2);
}
fclose(var0);
fclose(var1);
return 1;
}
function220(arg0)
{
new var0 = strlen(arg0);
if(!arg0)
{
return 0;
}
if(arg0[var0 - 1] == 10 || arg0[var0 - 1] == 13)
{
arg0[var0 - 1] = 0;
if(!arg0)
{
return 0;
}
if(arg0[var0 - 2] == 10 || arg0[var0 - 2] == 13)
{
arg0[var0 - 2] = 0;
}
}
return 0;
}
function448(arg0, arg1, arg2)
{
new var0[75];
new var1 = 0;
var0[0] = 0;
if(strlen(arg0) <= arg1)
{
return var0;
}
if(strlen(arg0) <= arg2 + arg1)
{
arg2 = strlen(arg0) - arg1;
}
if(0 >= arg2)
{
return var0;
}
for(var1 = arg1; arg2 + arg1 > var1; var1++)
{
var0[var1 - arg1] = arg0[var1];
if(!arg0[var1])
{
return var0;
}
}
var0[arg2] = 0;
return var0;
}
function70C(arg0, arg1)
{
new var0 = strlen(arg1);
new var1 = 0;
for(var1 = 0; var1 < var0; var1++)
{
arg0[var1] = arg1[var1];
}
arg0[var0] = 0;
return 0;
}
function800(arg0, arg1, arg2)
{
if(strlen(arg0) != strlen(arg1))
{
return 0;
}
if(!strcmp(arg0, arg1, arg2))
{
return 1;
}
return 0;
}
function8C4(arg0, &arg1, arg2)
{
new var0 = strlen(arg0);
new var1 = arg1;
new var2[75];
while(arg1 < var0 && arg0[arg1] != arg2 && arg1 - var1 < 74)
{
var2[arg1 - var1] = arg0[arg1];
arg1++;
}
var2[arg1 - var1] = 0;
if(arg1 < var0 && arg0[arg1] == arg2)
{
arg1++;
}
return var2;
}
functionB7C(arg0)
{
new var0[75];
var0[0] = 0;
if(!arg0)
{
return var0;
}
new var1 = 0;
for(var1 = 0; strlen(arg0) > var1; var1++)
{
var0[var1] = tolower(arg0[var1]);
}
var0[strlen(arg0)] = 0;
return var0;
}
functionD34(arg0)
{
new var0[75];
var0[0] = 0;
if(strfind(arg0, "=", true, 0) == -1)
{
return var0;
}
function70C(var0, functionB7C(function448(arg0, 0, strfind(arg0, "=", true, 0))));
return var0;
}
functionEC8(arg0)
{
new var0[75];
var0[0] = 0;
if(strfind(arg0, "=", true, 0) == -1)
{
return var0;
}
function70C(var0, function448(arg0, strfind(arg0, "=", true, 0) + 1, strlen(arg0)));
return var0;
}
function1054(arg0, arg1, arg2)
{
new File:var0 = 0, File:var1 = 0;
new var2 = 0;
new var3[75];
if(!arg1)
{
return 0;
}
format(var3, 75, "%s.part", arg0);
var0 = fopen(arg0, 0);
if(!var0)
{
return 0;
}
fremove(var3);
var1 = fopen(var3, 1);
while(fread(var0, var3, 75))
{
function220(var3);
if(!var2 && function800(functionD34(var3), arg1, true))
{
format(var3, 75, "%s=%s", arg1, arg2);
var2 = 1;
}
fwrite(var1, var3);
fwrite(var1, "\r\n");
}
if(!var2)
{
format(var3, 75, "%s=%s", arg1, arg2);
fwrite(var1, var3);
fwrite(var1, "\r\n");
}
fclose(var0);
fclose(var1);
format(var3, 75, "%s.part", arg0);
if(function8(var3, arg0))
{
return fremove(var3);
}
return 0;
}
function150C(arg0, arg1)
{
new File:var0 = 0;
new var1[75];
new var2[75];
var1[0] = 0;
var0 = fopen(arg0, 0);
if(!var0)
{
return var1;
}
while(fread(var0, var1, 75))
{
function220(var1);
if(function800(functionD34(var1), arg1, true))
{
var2[0] = 0;
strcat(var2, functionEC8(var1), 75);
fclose(var0);
return var2;
}
}
fclose(var0);
return var1;
}
public OnFilterScriptInir()
{
print("Sucessfully started!");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
main()
{
return 0;
}
public OnGameModeInit()
{
return 1;
}
public OnGameModeExit()
{
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
return 1;
}
public OnPlayerConnect(playerid)
{
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
return 1;
}
public OnPlayerText(playerid, text)
{
new var0[256];
new var1[128];
new var2 = 0;
var0 = function8C4(text, var2, 32);
if(!strcmp(var0, "!gotolocadmin", true))
{
var1 = function8C4(text, var2, 32);
if(!strlen(var1))
{
SendClientMessage(playerid, 0x33AA33AA, "USAGE: !gotoloc [Name]");
}
if(!IsLocationExist(var1))
{
SendClientMessage(playerid, 0x33AA33AA, "InValid Loc");
}
else
{
GotoLoc(playerid, var1);
}
return 1;
}
if(!strcmp(var0, "!saveloc", true))
{
var1 = function8C4(text, var2, 32);
if(!strlen(var1))
{
SendClientMessage(playerid, 0x04A36BF, "** pm >> USAGE: !saveloc <location>");
}
if(GetLocExists(var1))
{
SendClientMessage(playerid, 0x04A36BF, "** pm >> This location already exists.");
}
else
{
SaveLoc(playerid, var1);
}
return 1;
}
return 0;
}
public GotoLoc(playerid, arg1)
{
new var0[4][128];
new var1[128];
function2354(function150C("/SavedLocations/Locations.ini", arg1), var0, 32);
SetPlayerPos(playerid, floatstr(var0[0]), floatstr(var0[1]), floatstr(var0[2]), 0, 0);
format(var1, 128, "location: %s : (%.4f %.4f %.4f)", arg1);
SendClientMessage(playerid, 0x33AA33AA, var1);
return 1;
}
public SaveLoc(playerid, arg1)
{
new Float:var0 = 0.0, Float:var1 = 0.0, Float:var2 = 0.0, var3[254], var4[256];
new var5[128];
GetPlayerPos(playerid, var0, var1, var2);
GetPlayerName(playerid, var3, 254);
format(var4, 256, "%.4f %.4f %.4f", var0, var1, var2, var3);
function1054("/SavedLocations/Locations.ini", arg1, var4);
format(var5, 128, "Saved As %s Coords = (%.4f %.4f %.4f.)", arg1, var0, var1, var2);
SendClientMessage(playerid, 0x33AA33AA, var5);
return 1;
}
public IsLocationExist(arg0)
{
new var0[128];
var0 = function150C("/SavedLocations/Locations.ini", arg0);
return 1;
}
public GetLocExists(arg0)
{
if(strcmp(var0, "0", true))
{
}
new var0[128];
var0 = function150C("/SavedLocations/Locations.ini", arg0);
return 1;
}
function2354(arg0, arg1, arg2)
{
if(strcmp(var0, "0", true))
{
}
new var0 = 0, var1 = 0;
new var2 = 0;
new var3 = 0;
while(strlen(arg0) >= var0)
{
if(arg0[var0] == arg2 || var0 == strlen(arg0))
{
var3 = strmid(arg1[var2], arg0, var1, var0, 128);
arg1[var2][var3] = 0;
var1 = var0 + 1;
var2++;
}
var0++;
}
return 1;
}
Errors:
E:\Legacy VCMP\pawno\new.pwn(8) : warning 213: tag mismatch
E:\Legacy VCMP\pawno\new.pwn(8) : warning 213: tag mismatch
E:\Legacy VCMP\pawno\new.pwn(9) : error 035: argument type mismatch (argument 1)
E:\Legacy VCMP\pawno\new.pwn(13) : error 035: argument type mismatch (argument 1)
E:\Legacy VCMP\pawno\new.pwn(14) : error 035: argument type mismatch (argument 1)
E:\Legacy VCMP\pawno\new.pwn(18) : error 035: argument type mismatch (argument 1)
E:\Legacy VCMP\pawno\new.pwn(25) : warning 203: symbol is never used: "arg1"
E:\Legacy VCMP\pawno\new.pwn(25) : warning 203: symbol is never used: "arg0"
E:\Legacy VCMP\pawno\new.pwn(29) : error 035: argument type mismatch (argument 1)
E:\Legacy VCMP\pawno\new.pwn(34) : error 028: invalid subscript (not an array or too many subscripts): "arg0"
E:\Legacy VCMP\pawno\new.pwn(34) : warning 215: expression has no effect
E:\Legacy VCMP\pawno\new.pwn(34) : error 001: expected token: ";", but found "]"
E:\Legacy VCMP\pawno\new.pwn(34) : error 029: invalid expression, assumed zero
E:\Legacy VCMP\pawno\new.pwn(34) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.0.3367 Copyright (c) 1997-2005, ITB CompuPhase
9 Errors.
I'd really appreciate any help.
Thanks