convert commands - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: convert commands (
/showthread.php?tid=314926)
convert commands -
genesis87 - 01.02.2012
hey folks im trying to convert old commands to new 0.3 but when i do /deposit 30 i keep getting Use: /deposit [AMOUNT]
old :
Код:
if(strcmp(cmd, "/deposit", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(CPS_IsPlayerInCheckpoint(playerid, cpbank))
{
if(BankRecentlyUsed[playerid] == 0)
{
if(strlen(tmp) == 0) return SendClientMessage(playerid, ERROR, "Use: /deposit [AMOUNT]");
else
{
if(strval(tmp) == 0) return SendClientMessage(playerid, ERROR, "The amount must be higher than 1.");
else
{
if(strval(tmp) > GetPlayerMoney(playerid)) return SendClientMessage(playerid, ERROR, "You do not have this amount.");
else
{
new string[150], string2[150];
SetPlayerBankCash(playerid, GetPlayerBankCash(playerid)+strval(tmp));
SendClientMessage(playerid, GREY, "|_| Bank |_|");
format(string, sizeof(string), "Amount deposited: $%d", strval(tmp));
format(string2, sizeof(string2), "Current state: $%d", GetPlayerBankCash(playerid));
SendClientMessage(playerid, WHITE, string);
SendClientMessage(playerid, WHITE, string2);
GivePlayerMoney(playerid, -strval(tmp));
printf("%s[ID:%d] deposited $%d. Location: Bank", name, playerid, strval(tmp));
return true;
}
}
}
}
else if(BankRecentlyUsed[playerid] >= 1) SendClientMessage(playerid, ERROR, "You have recently robbed the Bank."); return true;
}
else return SendClientMessage(playerid, ERROR, "You must be on the Bank to use this command!");
}
Код:
CMD:deposit(playerid, params[])
{
new cmd[256], idx, tmp[256], name[MAX_PLAYER_NAME], file[256];
GetPlayerName(playerid, name, sizeof(name));
cmd = strtok(params, idx);
tmp = strtok(params, idx);
if(CPS_IsPlayerInCheckpoint(playerid, cpbank))
{
if(BankRecentlyUsed[playerid] == 0)
{
if(strlen(tmp) == 0) return SendClientMessage(playerid, ERROR, "Use: /deposit [AMOUNT]");
else
{
if(strval(tmp) == 0) return SendClientMessage(playerid, ERROR, "The amount must be higher than 1.");
else
{
if(strval(tmp) > GetPlayerMoney(playerid)) return SendClientMessage(playerid, ERROR, "You do not have this amount.");
else
{
new string[150], string2[150];
SetPlayerBankCash(playerid, GetPlayerBankCash(playerid)+strval(tmp));
SendClientMessage(playerid, GREY, "|_| Bank |_|");
format(string, sizeof(string), "Amount deposited: $%d", strval(tmp));
format(string2, sizeof(string2), "Current state: $%d", GetPlayerBankCash(playerid));
SendClientMessage(playerid, WHITE, string);
SendClientMessage(playerid, WHITE, string2);
GivePlayerMoney(playerid, -strval(tmp));
printf("%s[ID:%d] deposited $%d. Location: Bank", name, playerid, strval(tmp));
return true;
}
}
}
}
else if(BankRecentlyUsed[playerid] >= 1) SendClientMessage(playerid, ERROR, "You have recently robbed the Bank."); return true;
}
else return SendClientMessage(playerid, ERROR, "You must be on the Bank to use this command!");
}
also im using mysql saving/loading, should i add it here as well or its fine to leave the update on OnplayerDisconnect ?
Код:
"UPDATE `playerinfo` SET `bank` = '%d', WHERE `user` = '%s'", GetPlayerBankCash(playerid), escpname(playerid));