10.05.2014, 12:53
hello
i have one problem.
When using the command give money to players = reset money
How do I solve this problem?
Command :
Thanks
-------------------
sorry. my bad english.
i have one problem.
When using the command give money to players = reset money
How do I solve this problem?
Код:
#include <a_samp> #define ResetMoneyBar ResetPlayerMoney #define UpdateMoneyBar GivePlayerMoney forward MoneyTimer(); public OnFilterScriptInit() { SetTimer("MoneyTimer", 1000, 1); return 1; } new Cash[MAX_PLAYERS]; stock GivePlayerCash(playerid, money) { Cash[playerid] += money; ResetMoneyBar(playerid);//Resets the money in the original moneybar, Do not remove! UpdateMoneyBar(playerid,Cash[playerid]);//Sets the money in the moneybar to the serverside cash, Do not remove! return Cash[playerid]; } stock SetPlayerCash(playerid, money) { Cash[playerid] = money; ResetMoneyBar(playerid);//Resets the money in the original moneybar, Do not remove! UpdateMoneyBar(playerid,Cash[playerid]);//Sets the money in the moneybar to the serverside cash, Do not remove! return Cash[playerid]; } stock ResetPlayerCash(playerid) { Cash[playerid] = 0; ResetMoneyBar(playerid);//Resets the money in the original moneybar, Do not remove! UpdateMoneyBar(playerid,Cash[playerid]);//Sets the money in the moneybar to the serverside cash, Do not remove! return Cash[playerid]; } stock GetPlayerCash(playerid) { return Cash[playerid]; } public OnPlayerConnect(playerid) { ResetPlayerCash(playerid); return 1; } public MoneyTimer() { new username[MAX_PLAYER_NAME]; for(new i=0; i<MAX_PLAYERS; i++) { if(IsPlayerConnected(i)) { if(GetPlayerCash(i) != GetPlayerMoney(i)) { ResetMoneyBar(i);//Resets the money in the original moneybar, Do not remove! UpdateMoneyBar(i,GetPlayerCash(i));//Sets the money in the moneybar to the serverside cash, Do not remove! new hack = GetPlayerMoney(i) - GetPlayerCash(i); GetPlayerName(i,username,sizeof(username)); printf("Player %s = money hack = $%d.", username,hack); } } } }
Код:
CMD:givemoney(playerid, params[]) { new id, money, reason[128]; if(PlayerInfo[playerid][pAdmin] <= 4) return SendClientMessage(playerid, 0xFFFFFFFF, "{FF9900}[Server] only to use admin level 5."); if(sscanf(params,"uds", id, money, reason)) return SendClientMessage(playerid, 0xFFFFFFFF, "{FF9900}[Server] Use: /givemoney [PlayerID/Name] [amount] [reason]"); if(!IsPlayerConnected(id)) return SendClientMessage(playerid,0xFFFFFFFF,"{FF9900}[Server] player not connected."); else { new Namep[MAX_PLAYER_NAME], polakiMessage[128]; new Nameid[MAX_PLAYER_NAME], polakiidMessage[128]; GetPlayerName(playerid, Namep, sizeof(Namep)); GetPlayerName(id, Nameid, sizeof(Nameid)); format(polakiMessage, sizeof(polakiMessage), "{FF0000}[Server] you, player %s(%d) [$%d] reason [%s].", Nameid, id, money, reason); SendClientMessage(playerid, 0xFFFFFFFF, polakiMessage); format(polakiidMessage, sizeof(polakiidMessage), "{FF0000}[Server] admin level 5 %s(%d) [$%d] reason [%s] you give.", Namep, playerid, money, reason); SendClientMessage(id, 0xFFFFFFFF, polakiidMessage); GivePlayerMoney(id, money); } return 1; }
-------------------
sorry. my bad english.