Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //:o
- #include <a_samp>
- #include <YSI\y_ini>
- #define PATH "/PlayerCoin/%s.ini"
- enum pInfo
- {
- pCoin,
- }
- new PlayerInfo[MAX_PLAYERS][pInfo];
- forward LoadUser_data(playerid,name[],value[]);
- public LoadUser_data(playerid,name[],value[])
- {
- INI_Int("Fa-Coins",PlayerInfo[playerid][pCoin]);
- return 1;
- }
- stock UserPath(playerid)
- {
- new string[128],playername[MAX_PLAYER_NAME];
- GetPlayerName(playerid,playername,sizeof(playername));
- format(string,sizeof(string),PATH,playername);
- return string;
- }
- public OnPlayerConnect(playerid)
- {
- if(fexist(UserPath(playerid)))
- {
- INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
- }
- else
- {
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File,"data");
- INI_WriteInt(File,"Fa-Coins",0);
- INI_Close(File);
- }
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- new INI:File = INI_Open(UserPath(playerid));
- INI_SetTag(File,"data");
- INI_WriteInt(File,"Fa-Coin",PlayerInfo[playerid][pCoin]);
- INI_Close(File);
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- if(!strcmp(cmdtext, "/mycoins", true)) // 3 is the length of /me
- {
- new str[128];
- GetPlayerName(playerid, str, sizeof(str));
- format(str, sizeof(str), "Name: %s Fa-Coins: %d", str, PlayerInfo[playerid][pCoin]);
- SendClientMessage(playerid,-1, str);
- return 1;
- }
- if(!strcmp(cmdtext, "/needcoin", true)) // 3 is the length of /me
- {
- GivePlayerCoin(playerid,20);
- new str[128];
- GetPlayerName(playerid, str, sizeof(str));
- format(str, sizeof(str), "Name: %s Fa-Coins: %d", str, PlayerInfo[playerid][pCoin]);
- SendClientMessage(playerid,-1, str);
- return 1;
- }
- return 0;
- }
- stock GivePlayerCoin(playerid,amount)
- {
- PlayerInfo[playerid][pCoin] += amount;
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment