Error (/Setcash)
#1

Hi there,

I have a problem with this command. (I'm using ladmin)
Example: When i use /setcash 0 1000, it gives 2000 (double cash) idk why. Someone can help me at this?


Here the command:
Quote:

dcmd_setcash(playerid,params[]) {
if(GetPVarInt(playerid,"InDeathMatch") == 1) return SendClientMessage(playerid,RED,"{E01B4C}You can't use this command here {FF9000}/leavedm or /exitrace");
if(PlayerInfo[playerid][Level] >= 6) {
new tmp[256], tmp2[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
if(!strlen(tmp) || !strlen(tmp2) || !IsNumeric(tmp2)) return SendClientMessage(playerid, red, "USAGE: /setcash [playerid] [amount]");
new player1 = strval(tmp), cash = strval(tmp2), string[128];
if(PlayerInfo[player1][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) {
CMDMessageToAdmins(playerid,"SETCASH");
format(string, sizeof(string), "You have set \"%s's\" cash to '$%d", pName(player1), cash); SendClientMessage(playerid,blue,string);
if(player1 != playerid) { format(string,sizeof(string),"Administrator \"%s\" has set your cash to '$%d'", pName(playerid), cash); SendClientMessage(player1,blue,string); }
SetPlayerMoney(player1, cash);
return GivePlayerMoney(player1, cash);
} else return SendClientMessage(playerid,red,"ERROR: Player is not connected");
} else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}

Thanks for reading ^^
Reply
#2

Remove this
PHP код:
SetPlayerMoney(player1cash); 
Reply
#3

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
Remove this
PHP код:
SetPlayerMoney(player1cash); 
I'm Gonna check it

EDIT: Fixed, thank you very much!
Reply
#4

replace SetPlayerMoney with ResetPlayerMoney(playerid); like below ;_;

PHP код:
dcmd_setcash(playerid,params[]) {
 if(
GetPVarInt(playerid,"InDeathMatch") == 1) return SendClientMessage(playerid,RED,"{E01B4C}You can't use this command here {FF9000}/leavedm or /exitrace");
 if(
PlayerInfo[playerid][Level] >= 6) {
 new 
tmp[256], tmp2[256], Indextmp strtok(params,Index), tmp2 strtok(params,Index);
 if(!
strlen(tmp) || !strlen(tmp2) || !IsNumeric(tmp2)) return SendClientMessage(playeridred"USAGE: /setcash [playerid] [amount]");
 new 
player1 strval(tmp), cash strval(tmp2), string[128];
 if(
PlayerInfo[player1][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
 if(
IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) {
 
CMDMessageToAdmins(playerid,"SETCASH");
 
format(stringsizeof(string), "You have set \"%s's\" cash to '$%d"pName(player1), cash); SendClientMessage(playerid,blue,string);
 if(
player1 != playerid) { format(string,sizeof(string),"Administrator \"%s\" has set your cash to '$%d'"pName(playerid), cash); SendClientMessage(player1,blue,string); }
 
ResetPlayerMoney(player1);
 return 
GivePlayerMoney(player1cash);
 } else return 
SendClientMessage(playerid,red,"ERROR: Player is not connected");
 } else return 
SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
 } 
Reply
#5

Quote:
Originally Posted by jlalt
Посмотреть сообщение
replace SetPlayerMoney with ResetPlayerMoney(playerid); like below ;_;

PHP код:
dcmd_setcash(playerid,params[]) {
 if(
GetPVarInt(playerid,"InDeathMatch") == 1) return SendClientMessage(playerid,RED,"{E01B4C}You can't use this command here {FF9000}/leavedm or /exitrace");
 if(
PlayerInfo[playerid][Level] >= 6) {
 new 
tmp[256], tmp2[256], Indextmp strtok(params,Index), tmp2 strtok(params,Index);
 if(!
strlen(tmp) || !strlen(tmp2) || !IsNumeric(tmp2)) return SendClientMessage(playeridred"USAGE: /setcash [playerid] [amount]");
 new 
player1 strval(tmp), cash strval(tmp2), string[128];
 if(
PlayerInfo[player1][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
 if(
IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) {
 
CMDMessageToAdmins(playerid,"SETCASH");
 
format(stringsizeof(string), "You have set \"%s's\" cash to '$%d"pName(player1), cash); SendClientMessage(playerid,blue,string);
 if(
player1 != playerid) { format(string,sizeof(string),"Administrator \"%s\" has set your cash to '$%d'"pName(playerid), cash); SendClientMessage(player1,blue,string); }
 
ResetPlayerMoney(player1);
 return 
GivePlayerMoney(player1cash);
 } else return 
SendClientMessage(playerid,red,"ERROR: Player is not connected");
 } else return 
SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
 } 
Thanks!! ^^

Now it works fine.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)