09.10.2009, 11:35
hey guys i have some problems with /givecash command and i know i fuck up alot
but here is forum and ppl who can help for that 
here is my command:
public OnPlayerCommandText(playerid, cmdtext[])
{
new string[256];
new playermoney;
new sendername[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
new cmd[256];
new giveplayerid, moneys, idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/givecash", true) == 0) {
new tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_RED, "USAGE: /givecash [playerid] [amount]");
return 1;
}
giveplayerid = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_RED, "USAGE: /givecash [playerid] [amount]");
return 1;
}
moneys = strval(tmp);
//printf("givecash_command: %d %d",giveplayerid,moneys);
if (IsPlayerConnected(giveplayerid)) {
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
playermoney = GetPlayerMoney(playerid);
if (moneys > 0 && playermoney >= moneys) {
GivePlayerMoney(playerid, (0 - moneys));
GivePlayerMoney(giveplayerid, moneys);
format(string, sizeof(string), "~w~You have sent ~g~$%d.", giveplayer,giveplayerid, moneys);
GameTextForPlayer(playerid,string,5000,5);
SendClientMessage(playerid,LIGHTBLUE,"You Sent $%d to %s (%d)!");
format(string, sizeof(string), "~w~You have recieved ~g~$%d.", moneys, sendername, playerid);
GameTextForPlayer(playerid,string,5000,5);
SendClientMessage(playerid,LIGHTBLUE,"%s (%d) Has Sent You $%d!");
printf("%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
}
else {
SendClientMessage(playerid, COLOR_RED, "Money Sending Fail!.");
}
}
else {
format(string, sizeof(string), "ID %d is not an active player.", giveplayerid);
SendClientMessage(playerid, COLOR_RED, string);
}
return 1;
}
// PROCESS OTHER COMMANDS
return 0;
}
and the problem is, when i type command it crash my server
i know i fuck up alot with strings but can you help me to make
when i send money to someone it write on scren You Send (money)
and in client message (chat) should write You Sent (money) to (player name +id)
and when player reciv You Recived (money)
in client message should write (player name +id) Has Sent You (money)
i know i fuck up something with strings cuz they are doing me much problems so i ask here for help, i hope you will help me
and if you dont know what i want i can explain again lol


here is my command:
public OnPlayerCommandText(playerid, cmdtext[])
{
new string[256];
new playermoney;
new sendername[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
new cmd[256];
new giveplayerid, moneys, idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/givecash", true) == 0) {
new tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_RED, "USAGE: /givecash [playerid] [amount]");
return 1;
}
giveplayerid = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_RED, "USAGE: /givecash [playerid] [amount]");
return 1;
}
moneys = strval(tmp);
//printf("givecash_command: %d %d",giveplayerid,moneys);
if (IsPlayerConnected(giveplayerid)) {
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
playermoney = GetPlayerMoney(playerid);
if (moneys > 0 && playermoney >= moneys) {
GivePlayerMoney(playerid, (0 - moneys));
GivePlayerMoney(giveplayerid, moneys);
format(string, sizeof(string), "~w~You have sent ~g~$%d.", giveplayer,giveplayerid, moneys);
GameTextForPlayer(playerid,string,5000,5);
SendClientMessage(playerid,LIGHTBLUE,"You Sent $%d to %s (%d)!");
format(string, sizeof(string), "~w~You have recieved ~g~$%d.", moneys, sendername, playerid);
GameTextForPlayer(playerid,string,5000,5);
SendClientMessage(playerid,LIGHTBLUE,"%s (%d) Has Sent You $%d!");
printf("%s(playerid:%d) has transfered %d to %s(playerid:%d)",sendername, playerid, moneys, giveplayer, giveplayerid);
}
else {
SendClientMessage(playerid, COLOR_RED, "Money Sending Fail!.");
}
}
else {
format(string, sizeof(string), "ID %d is not an active player.", giveplayerid);
SendClientMessage(playerid, COLOR_RED, string);
}
return 1;
}
// PROCESS OTHER COMMANDS
return 0;
}
and the problem is, when i type command it crash my server

when i send money to someone it write on scren You Send (money)
and in client message (chat) should write You Sent (money) to (player name +id)
and when player reciv You Recived (money)
in client message should write (player name +id) Has Sent You (money)
i know i fuck up something with strings cuz they are doing me much problems so i ask here for help, i hope you will help me

and if you dont know what i want i can explain again lol