19.12.2017, 08:03
Sorry for making the same thread as before .. but I think no one understands me, so I will make a new thread to make sure anyone understand what am I saying.
I use JakHouse system for my server, and my gamemode have a serverside money function. So, when I try to buy a house, it makes my money turn negative, yes I use CallRemoteFunction to call my serverside money in my gamemode. Same goes to storing cash (jakhouse). And btw the serverside money that I use is the one from this tutorial : https://sampforum.blast.hk/showthread.php?tid=71136
Serverside money function inside my gamemode :
Buyhouse in JakHouse :
Store cash thing from JakHouse :
I hope you guys understand .. I'm stuck at this problem for 4 days now ..
I use JakHouse system for my server, and my gamemode have a serverside money function. So, when I try to buy a house, it makes my money turn negative, yes I use CallRemoteFunction to call my serverside money in my gamemode. Same goes to storing cash (jakhouse). And btw the serverside money that I use is the one from this tutorial : https://sampforum.blast.hk/showthread.php?tid=71136
Serverside money function inside my gamemode :
PHP код:
forward GivePlayerCash(playerid, money);
public GivePlayerCash(playerid, money)
{
Account[playerid][Money] += money;
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, Account[playerid][Money]);
return Account[playerid][Money];
}
forward SetPlayerCash(playerid, money);
public SetPlayerCash(playerid, money)
{
Account[playerid][Money] = money;
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, Account[playerid][Money]);
return Account[playerid][Money];
}
forward ResetPlayerCash(playerid);
public ResetPlayerCash(playerid)
{
Account[playerid][Money] = 0;
ResetPlayerMoney(playerid);
GivePlayerCash(playerid, Account[playerid][Money]);
return Account[playerid][Money];
}
forward GetPlayerCash(playerid);
public GetPlayerCash(playerid)
{
return Account[playerid][Money];
}
PHP код:
CMD:buyhouse(playerid, params[])
{
new
string[128]
;
new i = h_ID[playerid];
if(i == -1) return SendClientMessage(playerid, COLOR_RED, "<!>[Server] Mana Umah , Aku xleh detect . Duduk leklok la aduh..");
if(IsPlayerInRangeOfPoint(playerid, 1.5, hInfo[i][hPickupP][0], hInfo[i][hPickupP][1], hInfo[i][hPickupP][2]))
{
if(hInfo[i][hSale] == 1) return SendClientMessage(playerid, COLOR_RED, "<!> This house isn't for sale.");
if(CallRemoteFunction("GetPlayerCash", "i", playerid) < hInfo[i][hPrice]) return SendClientMessage(playerid, COLOR_RED, "<!>[InvalidMoney] Kau tak cukup duit , jadi homeless sng.");
if(jpInfo[playerid][OwnedHouses] > 2) return SendClientMessage(playerid, COLOR_RED, "<!> Max house limit is 3! You can't buy more house than that!");
jpInfo[playerid][OwnedHouses]++;
jpInfo[playerid][p_SpawnPoint][0] = hInfo[i][hEnterPos][0];
jpInfo[playerid][p_SpawnPoint][1] = hInfo[i][hEnterPos][1];
jpInfo[playerid][p_SpawnPoint][2] = hInfo[i][hEnterPos][2];
jpInfo[playerid][p_SpawnPoint][3] = hInfo[i][hEnterPos][3];
jpInfo[playerid][p_Interior] = hInfo[i][hInterior];
hInfo[i][hSale] = 1;
hInfo[i][hLocked] = 0;
format(hInfo[i][hOwner], 256, "%s", p_Name(playerid));
CallRemoteFunction("GivePlayerCash", "dd", playerid, -hInfo[i][hPrice]);
format(string, 128, "You have bought this house for $%d.", hInfo[i][hPrice]);
SendClientMessage(playerid, COLOR_YELLOW, string);
SaveHouse(i);
DestroyDynamicCP(hInfo[i][hCP]);
DestroyDynamicPickup(hInfo[i][hPickup]);
DestroyDynamicMapIcon(hInfo[i][hMapIcon]);
DestroyDynamic3DTextLabel(hInfo[i][hLabel]);
LoadHouse(i);
}
else
{
SendClientMessage(playerid, COLOR_RED, "[Server] Mana Umah , Aku xleh detect . Duduk leklok la aduh..");
}
return 1;
}
PHP код:
if(dialogid == DIALOG_HSTOREC)
{
if(response)
{
if(!strlen(inputtext))
{
ShowPlayerDialog(playerid, DIALOG_HSTOREC, DIALOG_STYLE_INPUT, ""green"Store Cash ($)",\
""white"You are now storing your money into your house safe.\nPut the amount of cash you want to store into your house. (E.G. 500)", "Configure", "Back");
return 1;
}
if(!isnumeric(inputtext))
{
ShowPlayerDialog(playerid, DIALOG_HSTOREC, DIALOG_STYLE_INPUT, ""green"Store Cash ($)",\
""white"You are now storing your money into your house safe.\nPut the amount of cash you want to store into your house. (E.G. 500)\n\n"red"[Error]Do you want to deposit alphabets ? LMAO.", "Configure", "Back");
return 1;
}
if(strval(inputtext) > CallRemoteFunction("GetPlayerCash", "i", playerid))
{
ShowPlayerDialog(playerid, DIALOG_HSTOREC, DIALOG_STYLE_INPUT, ""green"Store Cash ($)",\
""white"You are now storing your money into your house safe.\nPut the amount of cash you want to store into your house. (E.G. 500)\n\n"red"[Error]You dont have that amount of money", "Configure", "Back");
return 1;
}
CallRemoteFunction("GivePlayerCash", "dd", -strval(inputtext));
hInfo[hid][MoneyStore] = hInfo[hid][MoneyStore] + strval(inputtext);
new string[128];
format(string, 128, "You have store your $%d into your house safe. ($%d over all in your safe)", strval(inputtext), hInfo[hid][MoneyStore]);
SendClientMessage(playerid, -1, string);
SaveHouse(hid);
DestroyDynamicCP(hInfo[hid][hCP]);
DestroyDynamicPickup(hInfo[hid][hPickup]);
DestroyDynamicMapIcon(hInfo[hid][hMapIcon]);
DestroyDynamic3DTextLabel(hInfo[hid][hLabel]);
LoadHouse(hid);
cmd_hmenu(playerid, "");
}
else
{
cmd_hmenu(playerid, "");
}
}