Coin System help -
Slaykler - 20.09.2012
Okay first off, I do not want a Filtersciprt so do not post a thread saying go here. I need help to finish my code off
So my code is completed from scratch for my coin system. At the moment It saves in the player file etc /stats shows the coins you have. But im stuck on my command to give coins. Now i know i have to define it. but this is were im lost.
Ill show you my coin Coding below. Hopefully you can help me out guys.
This part is under enum PInfo {
Then when a player connects It checks the player coins using this
Code:
PlayerInfo[playerid][pCoins] = 0;
Then its move to when a player Registers
Code:
format(var, 64, "Coins=%d\n",PlayerInfo[playerid][pCoins]);fwrite(hFile, var);
When the Player Logs IN
Code:
if( strcmp( key , "Coins" , true ) == 0 ) { val = ini_GetValue( Data ); PlayerInfo[playerid][pCoins] = strval( val ); }
Then it comes to this part which may be the reason - It loads the coins but wont let me set player coins from in game - This part is Public UpdatePlayerInfo
Code:
new var[64];
format(var, 64, "Key=%s\n", PlayerInfo[playerid][pKey]);fwrite(hFile, var);
PlayerInfo[playerid][pMoney] = Otman_GetPlayerMoney(playerid);
PlayerInfo[playerid][pCoins] = GetPlayerCoins(playerid);<< I tried defining getplayercoins but no success
format(var, 64, "Level=%d\n",PlayerInfo[playerid][pLevel]);fwrite(hFile, var);
format(var, 64, "AdminLevel=%d\n",PlayerInfo[playerid][pAdmin]);fwrite(hFile, var);
This is under updateplayerinfo also, about 12 lines below the one above. This is a copy of my money system. I just want a coin system. It works i just need it to load and save coins and be able to give coins in game /givecoins
Code:
format(var, 64, "Coins=%d\n",PlayerInfo[playerid][pCoins]);fwrite(hFile, var);
Coin line before it shows you stats
Code:
new coins = PlayerInfo[targetid][pCoins];
This is the /stats Coin line
Code:
format(coordsstring, sizeof(coordsstring), "Level: %d || Gender: %s || Age: %d || City: %s || Coins: %d", level,atext,age,otext,coins);
SendClientMessage(playerid, COLOR_WHITE,coordsstring);
And finally heres the command to give coins.
Code:
if(strcmp(cmd, "/givecoins", true) == 0)
{
if (PlayerInfo[playerid][pAdmin] >= 6)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_FAILCMD, "TIP: {FFFFFF}/givecoins [ID or Name/Part of name] [Coins]");
return 1;
}
new playa;
new coins;
playa = ReturnUser(tmp);
tmp = strtok(cmdtext, idx);
coins = strval(tmp);
if (Logged[playa])
{
if(IsPlayerConnected(playa))
{
if(playa != INVALID_PLAYER_ID)
{
GetPlayerName(playerid, sendername, sizeof(sendername));
GetPlayerName(playa, giveplayer, sizeof(giveplayer));
format(string, sizeof(string), "> You Have Given Player %s $%d", giveplayer, coins);
SendClientMessage(playerid,COLOR_UPGRADEBLUE, string);
format(string, sizeof(string), "> Admin %s Gave You $%d", sendername, coins);
SendClientMessage(playa,COLOR_UPGRADEBLUE, string);
return 1;
}
}
}
}
return 1;
}
Please Help Me Out, If you can help me out or Make me a system that is not a Filterscript. I will gladly make a donation to your paypal account
The money system, you can giveplayermoney and takeplayermoney or setplayermoney.
But if i use that for my coin system it just adds to the cash in hand
Re: Coin System help -
TaLhA XIV - 20.09.2012
Your script was using tooooooo old ways and much much slower ways so I made one for you:
pawn Code:
CMD:givecoins(playerid,params[])
{
if(PlayerInfo[playerid][pAdmin] >= 6)
{
new target;
new coins;
if(sscanf(params, "ui", target, coins)) return SendClientMessage(playerid, -1, "Usage: /givecoins [Part of Name/Player ID] [Amount]");
if(!IsPlayerConnected(target))SendClientMessage(playerid,-1,"Player is not connected!");
{
if(PlayerInfo[playerid][pCoin] < coins)return SendClientMessage(playerid,-1,"You do not have enought coins!");
new tname,name;
new str[226];
{
tname = GetPlayerName(target, str, sizeof(str));
name = GetPlayerName(playerid, str, sizeof(str));
format(str, sizeof(str), "INFO: You gave %s %d coins.",tname,coins);
SendClientMessage(playerid,-1,str);
format(str, sizeof(str), "INFO: %s gave you %d coins.",name,coins);
SendClientMessage(playerid,-1,str);
PlayerInfo[playerid][pCoin] -= coins;
PlayerInfo[target][pCoin] += coins;
}
}
}
return 1;
}
Tell me if this works.