Suggestion file, Y_Ini.
#1

So, I made a suggestion filterscript.

pawn Код:
#include <a_samp>
#include <zcmd>
#include <sscanf>
#include <YSI\y_ini>

#define PATH "/Sugestii/%s.ini"

stock SugPath(playerid)
{
    new string[128],playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid,playername,sizeof(playername));
    format(string,sizeof(string),PATH,playername);
    return string;
}

CMD:sugestie(playerid, params[])
{
    new Suggestion;
    if(sscanf(params,"s", Suggestion)) return SendClientMessage(playerid, -1, "{FFCC33}Folosire: {15FF00}/Sugestie [Sugestie]");
    new INI:File = INI_Open(SugPath(playerid));
    INI_SetTag(File,"Sugestii");
    INI_WriteInt(File,"Sugestie: ", Suggestion);
    INI_Close(File);
    SendClientMessage(playerid, -1, "{FFCC33}Sugestia ta a fost trimisă owner-ului: {FF0000}Teddy {FFCC33}. Vă multumim!");
    return 1;
}
A problem it's, because when I use command if it's more characters than 5 it's show me 'Unknow Error', but if it's less than 5 characters, then it's works fine, but in file, it's showin' me something like:

pawn Код:
[Sugestii]
Sugestie: = 68;
Sugestie: = 68;
Sugestie: = 68;
What's wrong in code?


EDIT: Because I made this thread, I want to know how many filterscripts you can have in 'filescripts' folder and in 'server.cfg'. There it's a limit, or not?

+Rep for helper.
Reply
#2

i think you have to make a string for that

yours
you did
pawn Код:
new Sugestion; // its wrong
pawn Код:
CMD:sugestie(playerid, params[])
{
    new Suggestion;
    if(sscanf(params,"s", Suggestion)) return SendClientMessage(playerid, -1, "{FFCC33}Folosire: {15FF00}/Sugestie [Sugestie]");
    new INI:File = INI_Open(SugPath(playerid));
    INI_SetTag(File,"Sugestii");
    INI_WriteInt(File,"Sugestie: ", Suggestion);
    INI_Close(File);
    SendClientMessage(playerid, -1, "{FFCC33}Sugestia ta a fost trimisă owner-ului: {FF0000}Teddy {FFCC33}. Vă multumim!");
    return 1;
}
mine
pawn Код:
new Sugestion[256];// this is correct ! so 256 is the size of string how many words a player can write in sugestion
pawn Код:
CMD:sugestie(playerid, params[])
{
    new Suggestion[256];
    if(sscanf(params,"s[256]", Suggestion)) return SendClientMessage(playerid, -1, "{FFCC33}Folosire: {15FF00}/Sugestie [Sugestie]");
    new INI:File = INI_Open(SugPath(playerid));
    INI_SetTag(File,"Sugestii");
    INI_WriteInt(File,"Sugestie: ", Suggestion);
    INI_Close(File);
    SendClientMessage(playerid, -1, "{FFCC33}Sugestia ta a fost trimisă owner-ului: {FF0000}Teddy {FFCC33}. Vă multumim!");
    return 1;
}

and here you got for limits

https://sampwiki.blast.hk/wiki/Limits
Reply
#3

While declaring 'Suggestion' under the command, declare it as an array, not as an integer. Also, since sscanf2, you've to include the size of the array while passing it with 's' specifier.
pawn Код:
new Suggestion[64];
if(sscanf(params, "s[64]", Suggestion))
I also want to note that you don't have to use 128 as the string size for the path stock. You could count the character limit of the directory and sum up it with 25 (MAX_PLAYER_NAME+1).

Edit: late.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)