help plz /givemoney cmd
#1

hi alll i make a script for cmd /givemoney and here it is

Код:
if (strcmp("/givemoney", cmdtext, true, 10) == 0||strcmp("/givemoney", cmdtext, true, 10) == 0)
{
    new
        Destination,
        Ammount,
        PlayerName[24],
        DestName[24],
        String[128];
	if(!cmdtext[50])return SendClientMessage(playerid, COLOR_LIGHTERBLUE, "Usage: /givemoney <playerid> <ammount>");
    if (GetPlayerMoney(playerid) < Ammount)
        return SendClientMessage(playerid, -1, "  Insufficent funds !");

    GetPlayerName(playerid, PlayerName, 24);
    GetPlayerName(Destination, DestName, 24);
    format(String, 128, "%s(%d) has sent you %d$", PlayerName, playerid, Ammount);
    SendClientMessage(Destination, -1, String);
    format(String, 128, "You've sent %d$ to %s(%d)", Ammount, DestName, Destination);
    SendClientMessage(playerid, -1, String);

    GivePlayerMoney(Destination, Ammount);
    GivePlayerMoney(playerid, -Ammount);
    return 1;
}
but i have those bugs

Код:
D:\PC_GTA.SanAndreas -(rip)-(ToeD)\samp\gamemodes\test.pwn(21) : error 010: invalid function or declaration
D:\PC_GTA.SanAndreas -(rip)-(ToeD)\samp\gamemodes\test.pwn(9) : error 010: invalid function or declaration
D:\PC_GTA.SanAndreas -(rip)-(ToeD)\samp\gamemodes\test.pwn(10) : error 010: invalid function or declaration
D:\PC_GTA.SanAndreas -(rip)-(ToeD)\samp\gamemodes\test.pwn(11) : error 010: invalid function or declaration
D:\PC_GTA.SanAndreas -(rip)-(ToeD)\samp\gamemodes\test.pwn(13) : warning 219: local variable "PlayerName" shadows a variable at a preceding level
D:\PC_GTA.SanAndreas -(rip)-(ToeD)\samp\gamemodes\test.pwn(13) : error 010: invalid function or declaration
D:\PC_GTA.SanAndreas -(rip)-(ToeD)\samp\gamemodes\test.pwn(14) : warning 219: local variable "Destination" shadows a variable at a preceding level
D:\PC_GTA.SanAndreas -(rip)-(ToeD)\samp\gamemodes\test.pwn(14) : error 025: function heading differs from prototype
D:\PC_GTA.SanAndreas -(rip)-(ToeD)\samp\gamemodes\test.pwn(15) : warning 219: local variable "String" shadows a variable at a preceding level
D:\PC_GTA.SanAndreas -(rip)-(ToeD)\samp\gamemodes\test.pwn(15) : error 010: invalid function or declaration
D:\PC_GTA.SanAndreas -(rip)-(ToeD)\samp\gamemodes\test.pwn(16) : warning 219: local variable "Destination" shadows a variable at a preceding level
D:\PC_GTA.SanAndreas -(rip)-(ToeD)\samp\gamemodes\test.pwn(16) : error 010: invalid function or declaration
D:\PC_GTA.SanAndreas -(rip)-(ToeD)\samp\gamemodes\test.pwn(16) : error 010: invalid function or declaration
D:\PC_GTA.SanAndreas -(rip)-(ToeD)\samp\gamemodes\test.pwn(16 -- 18) : error 025: function heading differs from prototype
D:\PC_GTA.SanAndreas -(rip)-(ToeD)\samp\gamemodes\test.pwn(16 -- 18) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase
plz help me and thank you

btw ( i want the cmd without sscanf ) thank to all your help
Reply
#2

pawn Код:
if (strcmp("/givemoney", cmdtext, true, 10) == 0)
{
     new tmp[128], tmp2[128], Index;
     tmp = strtok(cmdtext,Index);
     tmp2 = strtok(cmdtext,Index);
     if(!strlen(tmp)) return SendClientMessage(playerid, -1, "Usage: /givemoney {FF0000}[Player ID] [Amount]");
     if(!strlen(tmp2)) return SendClientMessage(playerid, -1, "Usage: /givemoney [Player ID] {FF0000}[Amount]");
     new player1, cash, string[256];
     player1 = strval(tmp);
     cash = strval(tmp2);
     if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID)
     {
          if(player1 == playerid) return SendClientMessage(playerid, -1, "ERROR: You can't give money to yourself!");
          if(cash > GetPlayerMoney(playerid)) return SendClientMessage(playerid, -1, "ERROR: Insufficent funds!");
          if(cash < 1) return SendClientMessage(playerid, -1, "ERROR: Invalid amount (Negative or zero)");
          new name[MAX_PLAYER_NAME], name1[MAX_PLAYER_NAME], string[256];
          GetPlayerName(playerid, name, sizeof(name)); GetPlayerName(player1, name1, sizeof(name1));
          format(string, sizeof(string), "You have given %s (%d) $%d.", name1, player1, cash);
          SendClientMessage(playerid, -1, string);
          format(string, sizeof(string), "%s (%d) has given you $%d.", name, playerid, cash);
          SendClientMessage(playerid, -1, string);
          GivePlayerMoney(playerid, -cash);
          GivePlayerMoney(player1, cash);
     }
     else return SendClientMessage(playerid, -1, "ERROR: This player is not connected!");
}
Reply
#3

well thx so much i will try it
Reply
#4

hey dude there is bug when we use the cmd it give us this message
Quote:

(nigative or zero)

and when i use the cmd on my id it give the other players 1$ all the time can you fix it plz ? and thanks for helping
Reply
#5

pawn Код:
if (strcmp("/givemoney", cmdtext, true, 10) == 0)
{
    new tmp [256], tmp2[256], Index;
    tmp  = strtok(params,Index);
    tmp2 = strtok(params,Index);
    if(!strlen(params)) return SendClientMessage(playerid,-1,"Usage: /givemoney [Player ID] [Amount]");
    if(strlen(tmp) == playerid) return SendClientMessage(playerid,-1,"ERROR: You can't give money to yourself!");
    if(!strlen(tmp2)) return SendClientMessage(playerid, -1, "ERROR: Amount not inserted!");
    new player1, money, name[MAX_PLAYER_NAME], name1[MAX_PLAYER_NAME], string[128];
    player1 = strval(tmp);
    money = strval(tmp2);
    if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID)
    {
        if(money > GetPlayerMoney(playerid))
        return SendClientMessage(playerid,-1,"ERROR: You don't have that amount of money!");
        GetPlayerName(playerid, name, sizeof(name));
        GetPlayerName(player1, name1, sizeof(name1));
        format(string,sizeof(string),"You have given %s $%d ", name, money);
        SendClientMessage(playerid,red,string);
        format(string,sizeof(string),"%s has given you $%d", name1, money);
        GivePlayerMoney(playerid, -money);
        GivePlayerMoney(player1, money);
        return SendClientMessage(player1,-1,string);
    }
     else return SendClientMessage(playerid, -1, "ERROR: This player is not connected!");
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)