Delete a file.
#1

How would I go about making a command so that when a player types /delete for example, it would delete a file with their name in script files folder named vehicles?

So basically

There is a file called First_Last.ini under Script Files / Vehicles
First_Last types /delete while connected to the server
The file First_Last.ini under Script Files / Vehicles is deleted.
Reply
#2

Код:
if(strcmp(cmd, "/delete", true) == 0)
	{
	new file;
	GetPlayerName(playerid, name, sizeof(name));
	format(file, sizeof(file), "/vehicles/%s.ini", udb_encode(name));
	if(dini_Exists(file))
		{
		dini_Remove(file);
		}
	return 1;
	}
Reply
#3

C:\Users\staples036\Downloads\RLRP V2\gamemodes\rlrp.pwn(30081) : error 017: undefined symbol "name"
C:\Users\staples036\Downloads\RLRP V2\gamemodes\rlrp.pwn(30081) : error 017: undefined symbol "name"
C:\Users\staples036\Downloads\RLRP V2\gamemodes\rlrp.pwn(30081) : error 029: invalid expression, assumed zero
Reply
#4

pawn Код:
if(strcmp(cmd, "/delete", true) == 0)
    {
    new name;
    new file;
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), "/vehicles/%s.ini", udb_encode(name));
    if(dini_Exists(file))
        {
        dini_Remove(file);
        }
    return 1;
    }
Reply
#5

With that I get

C:\Users\staples036\Downloads\RLRP V2\filterscripts\cars5.pwn(395) : error 035: argument type mismatch (argument 2)
C:\Users\staples036\Downloads\RLRP V2\filterscripts\cars5.pwn(395) : error 035: argument type mismatch (argument 2)
C:\Users\staples036\Downloads\RLRP V2\filterscripts\cars5.pwn(396) : error 035: argument type mismatch (argument 1)
C:\Users\staples036\Downloads\RLRP V2\filterscripts\cars5.pwn(396) : error 035: argument type mismatch (argument 1)
C:\Users\staples036\Downloads\RLRP V2\filterscripts\cars5.pwn(397) : error 017: undefined symbol "dini_Exists"
C:\Users\staples036\Downloads\RLRP V2\filterscripts\cars5.pwn(399) : error 017: undefined symbol "dini_Remove"
C:\Users\staples036\Downloads\RLRP V2\filterscripts\cars5.pwn(394) : warning 203: symbol is never used: "file"
C:\Users\staples036\Downloads\RLRP V2\filterscripts\cars5.pwn(393) : warning 203: symbol is never used: "name"
Reply
#6

Quote:
Originally Posted by -eXo
With that I get

C:\Users\staples036\Downloads\RLRP V2\filterscripts\cars5.pwn(395) : error 035: argument type mismatch (argument 2)
C:\Users\staples036\Downloads\RLRP V2\filterscripts\cars5.pwn(395) : error 035: argument type mismatch (argument 2)
C:\Users\staples036\Downloads\RLRP V2\filterscripts\cars5.pwn(396) : error 035: argument type mismatch (argument 1)
C:\Users\staples036\Downloads\RLRP V2\filterscripts\cars5.pwn(396) : error 035: argument type mismatch (argument 1)
C:\Users\staples036\Downloads\RLRP V2\filterscripts\cars5.pwn(397) : error 017: undefined symbol "dini_Exists"
C:\Users\staples036\Downloads\RLRP V2\filterscripts\cars5.pwn(399) : error 017: undefined symbol "dini_Remove"
C:\Users\staples036\Downloads\RLRP V2\filterscripts\cars5.pwn(394) : warning 203: symbol is never used: "file"
C:\Users\staples036\Downloads\RLRP V2\filterscripts\cars5.pwn(393) : warning 203: symbol is never used: "name"
which are line 395 - 399?
Reply
#7

Quote:

GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), "/vehicles/%s.ini", udb_encode(name));
if(dini_Exists(file))
{
dini_Remove(file);

Reply
#8

pawn Код:
if(strcmp(cmd, "/delete", true) == 0)
    {
    new name[MAX_PLAYER_NAME];
    new file[128];
    GetPlayerName(playerid, name, sizeof(name));
    format(file, sizeof(file), "/vehicles/%s.ini", udb_encode(name));
    if(dini_Exists(file))
        {
        dini_Remove(file);
        }
    return 1;
    }
guess like that if there are more errors tell me
Reply
#9

C:\Users\staples036\Downloads\RLRP V2\filterscripts\cars5.pwn(396) : error 017: undefined symbol "udb_encode"
C:\Users\staples036\Downloads\RLRP V2\filterscripts\cars5.pwn(397) : error 017: undefined symbol "dini_Exists"
C:\Users\staples036\Downloads\RLRP V2\filterscripts\cars5.pwn(399) : error 017: undefined symbol "dini_Remove"
Reply
#10

Quote:
Originally Posted by -eXo
C:\Users\staples036\Downloads\RLRP V2\filterscripts\cars5.pwn(396) : error 017: undefined symbol "udb_encode"
C:\Users\staples036\Downloads\RLRP V2\filterscripts\cars5.pwn(397) : error 017: undefined symbol "dini_Exists"
C:\Users\staples036\Downloads\RLRP V2\filterscripts\cars5.pwn(399) : error 017: undefined symbol "dini_Remove"
add
pawn Код:
#include <dini>
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)