Command error
#1

When player wanna send money to player it's says unknown command idk why

Код:
CMD:givecash(playerid,params[])
{
   new
   id,
   amount,
   l_string[200],
   name[MAX_PLAYERS],
   name2[MAX_PLAYERS],
   ID,
   string8[200];
   if(sscanf(params,"ui",id,amount)) return SendClientMessage(playerid,red,"/givecash [id] [amount]");
   if(GetPlayerMoney(playerid) < amount) return SendClientMessage(playerid,RED,"You don't have enought cash");
   if(amount < 0) return SendClientMessage(playerid,RED,"You have entered an invalid amount");
   if(id == playerid) return SendClientMessage(playerid,RED,"You can't give money to yourself.");
   F_GivePlayerMoney(playerid,-amount);
   F_GivePlayerMoney(id,amount);
   GetPlayerName(playerid,name,25);
   format(l_string,128,"%s has given to you the amount of cash: %i$",name,amount);
   SendClientMessage(id,COLOR_LIME,l_string);

   GetPlayerName(ID, name2, sizeof(name2));
   format(string8, sizeof(string8),"You have transfered %i$ to %s",amount,name2);
   SendClientMessage(playerid, COLOR_LIME, string8);
   return 1;
}
Reply
#2

PHP код:
   name[MAX_PLAYERS],
   
name2[MAX_PLAYERS], 
It's MAX_PLAYER_NAME.
Try to optimize your code a bit.
Reply
#3

Works but now this message shows name of player who send money no of player who receive.
Код:
format(string8, sizeof(string8),"You have transfered %i$ to %s",amount,name2);
Reply
#4

PHP код:
GetPlayerName(IDname2sizeof(name2)); 
Its id not ID
Reply
#5

okay
Reply
#6

Quote:
Originally Posted by Mijata
Посмотреть сообщение
Yea but when i put id two messages sents to one player
Is said to change the ID to id in GetPlayerName dont change playerid to id in sendclientmessage

PHP код:
CMD:givecash(playerid,params[])
{
   new
   
id,
   
amount,
   
string[70],
   
name[MAX_PLAYERS];
   if(
sscanf(params,"ui",id,amount)) return SendClientMessage(playerid,red,"/givecash [id] [amount]");
   if(
GetPlayerMoney(playerid) < amount) return SendClientMessage(playerid,RED,"You don't have enought cash");
   if(
amount 0) return SendClientMessage(playerid,RED,"You have entered an invalid amount");
   if(
id == playerid) return SendClientMessage(playerid,RED,"You can't give money to yourself.");
   
F_GivePlayerMoney(playerid,-amount);
   
F_GivePlayerMoney(id,amount);
   
//Message to reciever
   
GetPlayerName(playerid,name,sizeof(name));
   
format(string,sizeof(string),"%s has given to you the amount of cash: %i$",name,amount);
   
SendClientMessage(id,COLOR_LIME,string);
   
//Mesage to sender
   
GetPlayerName(idnamesizeof(name));
   
format(stringsizeof(string),"You have transfered %i$ to %s",amount,name);
   
SendClientMessage(playeridCOLOR_LIMEstring);
   return 
1;

Actually it only require that much variables above code will work.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)