Saving something in Files (i thing its simple , but i cant) - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Saving something in Files (i thing its simple , but i cant) (
/showthread.php?tid=41061)
Saving something in Files (i thing its simple , but i cant) -
mirkoiz - 24.06.2008
Hello all.
So you all know the Pcash system , right?
So i do rename all to Euro.
Here my renamed script:
Code:
/*============== EURO SCRIPT BY BBOY92 ======================================
============== AT FIRST A LOT OF THANKS TO Zezombia for the Base Script ===
============== THIS IS AN OTHER CASH (DONT LIKE DOLLAR) ===================
============== MUCH FUN WITH IT ==========================================
============== TIP: USE /eurohelp TO SEE THE COMMANDS =====================
=========================================================================*/
#include <a_samp>
#include <euro>
#define FILTERSCRIPT
#if defined FILTERSCRIPT
#define red 0xFF0000AA
#define green 0x33FF33AA
public OnFilterScriptInit()
{
print("--------------------------------------");
print(" Euro Script by Bboy92 (Base Script by Zezombia)");
print("--------------------------------------");
return 1;
}
#endif
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
if(strcmp("/giveeuro", cmd, true) == 0)
{
new tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, red, "Correct Useage : /giveeuro [Playerid] [ammount]");
if(strval(tmp) == playerid) return SendClientMessage(playerid, red, "You cant give Euro to yourself");
if(IsPlayerConnected(strval(tmp)) == 0) return SendClientMessage(playerid, red, "This Player is not Logged in");
new tmp2[256];
tmp2 = strtok(cmdtext, idx);
if(!strlen(tmp2)) return SendClientMessage(playerid, red, "Correct Useage : /giveeuro [Playerid] [ammount]");
new player = strval(tmp);
new ammount = strval(tmp2);
if(GetPlayerEuro(playerid) < ammount) return SendClientMessage(playerid, red, "Correct Useage : /giveeuro [Playerid] [ammount]");
new pname[MAX_PLAYER_NAME];
GetPlayerName(player, pname, sizeof(pname));
new oname[MAX_PLAYER_NAME];
GetPlayerName(playerid, oname, sizeof(oname));
new string[256];
format(string, sizeof(string), "You give %d Euro to %s", ammount, pname);
SendClientMessage(playerid, green, string);
format(string, sizeof(string), "You have been given %d euro by %s", ammount, oname);
SendClientMessage(player, green, string);
GivePlayerEuro(player, ammount);
GivePlayerEuro(playerid, -ammount);
return 1;
}
if(strcmp("/converteuro", cmd, true) == 0)
{
new tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, red, "Correct Useage : /converteuro [ammount]");
new ammount = strval(tmp);
if(GetPlayerEuro(playerid) < ammount) return SendClientMessage(playerid, red, "You dont have enough Euro");
new string[256];
format(string, sizeof(string), "You have converted %d euro", ammount);
SendClientMessage(playerid, green, string);
GivePlayerEuro(playerid, -ammount);
GivePlayerMoney(playerid, ammount);
return 1;
}
if (strcmp("/myeuro", cmdtext, true) == 0)
{
new string[256];
format(string, sizeof(string), "You have currently %d Euro", GetPlayerEuro(playerid));
SendClientMessage(playerid, green, string);
return 1;
}
if(strcmp("/giveadmineuro", cmdtext, true) == 0)
{
if(IsPlayerAdmin(playerid) == 0) return SendClientMessage(playerid, red, "You are not an Administrator");
GivePlayerEuro(playerid, 1000);
SendClientMessage(playerid, green, "You got 1000 Euro from the Server");
return 1;
}
return 0;
}
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
Problem is : I need to save the "Euro" in a file like Username.euro
Can any 1 help me ?? and finish this "DAMM" Script??
Thanks a lot !!!
P.s: The first one who finish the Script for me , will get Credits in this FS
Friendly Greetings:
Mirkoit aka Bboy92
Re: Saving something in Files (i thing its simple , but i cant) -
mastasquizy - 03.08.2008
try using dudb (search for it)
Re: Saving something in Files (i thing its simple , but i cant) -
coole210 - 02.06.2009
Okay try defining this : #define PATH "scriptfiles/username.euro"
EXAMPLE :
Code:
if (strcmp("/myeuro", cmdtext, true) == 0)
{
new string[256];
format(string, sizeof(string), "You have currently %d Euro", GetPlayerEuro(playerid));
SendClientMessage(playerid, green, string, PATH);
return 1;
}
But instead of /myeuro or something add it to your Saving system (e.g. /register and /login script)