PDA

View Full Version : convert dini to y_Ini


DerickClark
12/04/2014, 03:21 PM
There anywhere I can add it as Y_Ini.
savin as Y_Ini

PlayerInfo[playerid][JoinMessage]

COMMAND:joinmessage(playerid, params[])
{
new string[128], file[128], pName[MAX_PLAYER_NAME];
if(isnull(params)) return SendClientMessage(playerid, COLOUR_RED, "USAGE: {FFFFFF}/joinmessage [message]");
format(string, sizeof(string), "You have set your Join Message to: %s", params[0]);
SendClientMessage(playerid, -1, string);
GetPlayerName(playerid, pName, sizeof(pName));
format(file, sizeof(file), "accounts/%s.ini", pName);
dini_Create(file);
dini_Set(file, "personalmsg", params[0]);
return 1;
}

Lidor124
12/04/2014, 03:25 PM
COMMAND:joinmessage(playerid, params[])
{
new string[128], file[128], pName[MAX_PLAYER_NAME];
if(isnull(params)) return SendClientMessage(playerid, COLOUR_RED, "USAGE: {FFFFFF}/joinmessage [message]");
format(string, sizeof(string), "You have set your Join Message to: %s", params[0]);
SendClientMessage(playerid, -1, string);
GetPlayerName(playerid, pName, sizeof(pName));
format(file, sizeof(file), "accounts/%s.ini", pName);
new INI:File = INI_Open(file);
INI_SetString(file, "personalmsg", PlayerInfo[playerid][JoinMessage]);
INI_Close(file);
return 1;
}

btw read this tutorial:
http://forum.sa-mp.com/showthread.php?t=175565

DerickClark
12/04/2014, 03:29 PM
COMMAND:joinmessage(playerid, params[])
{
new string[128], file[128], pName[MAX_PLAYER_NAME];
if(isnull(params)) return SendClientMessage(playerid, COLOUR_RED, "USAGE: {FFFFFF}/joinmessage [message]");
format(string, sizeof(string), "You have set your Join Message to: %s", params[0]);
SendClientMessage(playerid, -1, string);
GetPlayerName(playerid, pName, sizeof(pName));
format(file, sizeof(file), "accounts/%s.ini", pName);
new INI:File = INI_Open(file);
INI_SetString(file, "personalmsg", PlayerInfo[playerid][JoinMessage]);
INI_Close(file);
return 1;
}

btw read this tutorial:
http://forum.sa-mp.com/showthread.php?t=175565
(2072) : error 017: undefined symbol "INI_SetString"
(2073) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.

COMMAND:joinmessage(playerid, params[])
{
new string[128], file[128], pName[MAX_PLAYER_NAME];
if(isnull(params)) return SendClientMessage(playerid, COLOUR_RED, "USAGE: {FFFFFF}/joinmessage [message]");
format(string, sizeof(string), "You have set your Join Message to: %s", PlayerInfo[playerid][JoinMessage]);
SendClientMessage(playerid, -1, string);
GetPlayerName(playerid, pName, sizeof(pName));
format(file, sizeof(file), "accounts/%s.ini", pName);
INI_SetString(file, "personalmsg", PlayerInfo[playerid][JoinMessage]);
INI_Close(file);
return 1;
}

Lidor124
12/04/2014, 03:45 PM
My bad, change SetString to WriteString.

DerickClark
12/04/2014, 03:47 PM
(2072) : error 035: argument type mismatch (argument 1)
(2073) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.

COMMAND:joinmessage(playerid, params[])
{
new string[128], file[128], pName[MAX_PLAYER_NAME];
if(isnull(params)) return SendClientMessage(playerid, COLOUR_RED, "USAGE: {FFFFFF}/joinmessage [message]");
format(string, sizeof(string), "You have set your Join Message to: %s", PlayerInfo[playerid][JoinMessage]);
SendClientMessage(playerid, -1, string);
GetPlayerName(playerid, pName, sizeof(pName));
format(file, sizeof(file), "accounts/%s.ini", pName);
INI_WriteString(file, "personalmsg", PlayerInfo[playerid][JoinMessage]);
INI_Close(file);
return 1;
}
Error Line:
1: INI_WriteString(file, "personalmsg", PlayerInfo[playerid][JoinMessage]);
2: INI_Close(file);

bool
12/04/2014, 03:56 PM
COMMAND:joinmessage(playerid, params[])
{
new string[128], INI:file[128], pName[MAX_PLAYER_NAME];
if(isnull(params)) return SendClientMessage(playerid, COLOUR_RED, "USAGE: {FFFFFF}/joinmessage [message]");
format(string, sizeof(string), "You have set your Join Message to: %s", PlayerInfo[playerid][JoinMessage]);
SendClientMessage(playerid, -1, string);
GetPlayerName(playerid, pName, sizeof(pName));
format(file, sizeof(file), "accounts/%s.ini", pName);
INI_Open(file);
INI_WriteString(file, "personalmsg", PlayerInfo[playerid][JoinMessage]);
INI_Close(file);
return 1;
}


INI_WriteString needs to have the length of the string on the end. Like if it's 32 characters it's

INI_WriteString(file, "personalmsg", PlayerInfo[playerid][JoinMessage], 32);

DerickClark
12/04/2014, 04:03 PM
Still 2 errors

error 035: argument type mismatch (argument 1)
error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.


@Bool, I have tried your code.

(2071) : warning 213: tag mismatch
(2072) : warning 213: tag mismatch
(2073) : error 035: argument type mismatch (argument 1)
(2074) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.

bool
12/04/2014, 04:16 PM
Still 2 errors

error 035: argument type mismatch (argument 1)
error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.


@Bool, I have tried your code.

(2071) : warning 213: tag mismatch
(2072) : warning 213: tag mismatch
(2073) : error 035: argument type mismatch (argument 1)
(2074) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.
Yeah uhh, I didn't actually fix it for you. I told you what I thought was wrong.

This compiles for me.

COMMAND:joinmessage(playerid, params[])
{
new string[128], pName[MAX_PLAYER_NAME], locfile[32];
if(isnull(params)) return SendClientMessage(playerid, -1, "USAGE: {FFFFFF}/joinmessage [message]");
format(string, sizeof(string), "You have set your Join Message to: %s", params);
SendClientMessage(playerid, -1, string);
GetPlayerName(playerid, pName, sizeof(pName));
format(locfile, sizeof(locfile), "accounts/%s.ini", pName);
new INI:file = INI_Open(locfile);
INI_WriteString(file, "personalmsg", params);
INI_Close(file);
return 1;
}

Take note though, I'm not actually saving the JoinMessage, but I am writing it to INI file, so when the player connects(Because it's a join message, right) Load it from the INI File then and assign it to PlayerInfo[playerid][JoinMessage];

DerickClark
12/04/2014, 04:32 PM
On player registerin
Creates the Message, like you have Test, if you wanna to edit it, you can use /joinmessage
format(File, sizeof(File), "accounts/%s.ini", ReturnName(playerid));
INI_WriteString(File, "JoinMessage", "50");
INI_Close(File);

error 035: argument type mismatch (argument 1)
error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


2 Errors.

bool
12/04/2014, 04:34 PM
I said LOAD it. Wherever you load your stuff, load your JoinMessage there.

DerickClark
12/04/2014, 04:52 PM
I tried to loaded, didn't read, but my files works.

DerickClark
12/04/2014, 11:30 PM
Still not loading or reading.

format(Message, sizeof(Message), "%s (%s)" ReturnName(playerid), INI_Get(file, "JoinMessage"));



stock INI_Get(filename[],key[])
{
new File:F,string[128];
new sname[24],sval[24];
F = fopen(filename,io_read);
if(!F) return sname;
while(fread(F,string))
{
sscanf(string,"p<=>s[24]s[24]",sname,sval);
if(!strcmp(sname,key)) {
sval[strlen(sval)-2] = 0;
fclose(F);
return sval;
}
}
fclose(F);
sname[0] = '\0';
return sname;
}COMMAND:joinmessage(playerid, params[])
{
new string[128], pName[MAX_PLAYER_NAME], locfile[32];
if(isnull(params)) return SendClientMessage(playerid, -1, "USAGE: {FFFFFF}/joinmessage [message]");
format(string, sizeof(string), "You have set your Join Message to: %s", params);
SendClientMessage(playerid, -1, string);
GetPlayerName(playerid, pName, sizeof(pName));
format(locfile, sizeof(locfile), "accounts/%s.ini", pName);
new INI:file = INI_Open(locfile);
INI_WriteString(file, "JoinMessage", params);
INI_Close(file);
return 1;
}There a way to add PlayerInfo[playerid][JoinMessage]?