1.Moramo definisati 2 variable!
Udjite u vas mod i nadjite gdje su vam definisani new i dodajte sledece:
new OldMoney;
new NewMoney;2.Sada moramo napraviti funkciju kada igracu dadnete novac da ga ne banuje:
Odite na kraj vaseg moda i dodajte:
forward GivePlayerMoneyEx(playerid,ammount);//Forward - this is how you call a new public
public GivePlayerMoneyEx(playerid,ammount)
{
//First the gonna have to set the OldMoney of the player , just in case .
OldMoney = GetPlayerMoney(playerid)//Get the money ( GetPlayerMoney ) they put it in the OldMoney var...
//Now we gotta define the new ammount of money the player holds , we gotta do it before we give him the money , so he wont get banned / kicked .
NewMoney = ammount;//Putting the ammount in the NewMoney var
//Now we gotta give the player some sweet cash
GivePlayerMoney(playerid,ammount);//default function : )
return 1;
}3😛rovjera novca
Moramo napraviti timer koji ce svakih 2 sekunde provjeravati.Ispod ovog sto ste zadnje dodali,dodajte i ovo:
forward CheckMoney();
public CheckMoney()
{
for(new i = 0; i < MAX_PLAYERS; I++)//This loop will check all players at one time
{
if(IsPlayerConnected(i))//Player is gotta be connected right ?
{
if(GetPlayerMoney(i) > NewMoney)//Getting player's money , checking if its more then his NewMoney(means he is hacking)
{
ResetPlayerMoney(i);//We gonna reset his money
GivePlayerMoney(i,OldMoney);//Give him his old money , as a punishment !
Ban(i);//Kick/Ban the poor kid
}
}
}
return 1;
}4:Namjestanje timera.
Pod OnGameModeInIt dodajte:
SetTimer("CheckMoney",2000,true);5:Zadji korak je podesavanje NewMoney kada se igrac konektuje na server.
OnPlayerConnect(playerid)
{
NewMoney = GetPlayerMoney(playerid);
return 1;
}Ako sam nesto pogresno uradio molim vas da me obavsjetite jer sam ono na brzinu uradio.
Orginalna tema:http://forum.sa-mp.com/showthread.php?t=292898