Setmon (Warchiefs v2.0)

Started by HTC, Jul 21, 2015, 08:12 PM

Previous topic - Next topic

HTC

How to fix?

Command:
                 else if ( cmd == "setmon" )
       {
          if ( IsNoob( player, cmd ) ) return 0;
         else if ( !text ) ePrivMessage( "Syntax, /c " + cmd + " <Nick/ID> <Money> ", player );
         local plr = GetPlayer( GetTok( text, " ", 1 ) );
         if ( !plr ) PrivMessage( "Unknown Player..", player );
         else
         {
            local mon = GetTok( text, " ", 2);
            if (!IsNum(mon)) ePrivMessage("Amount Must Be In Numbers..",player);
            else
            {
            PrivMessage(" Admin " + player.Name + " Set Money Of " + plr.Name + " To: " + mon + ".",player);
               IncCash( plr, mon.tointeger() );
            }
         }
         }
Erro:

[SCRIPT]  OnPlayerCommand Error: parameter 1 has an invalid type 'null' ; expected: 'string'
[SCRIPT]  OnPlayerCommand Error: parameter 1 has an invalid type 'string' ; expected: 'instance'

.

#1
Any specific line in there? For f*s sake people. Do you have any logic? If you can't identify the line at least post a screen shot and make sure to resize the console window to capture the whole error output.

I think this condition was satisfied when you typed that command.
          if ( IsNoob( player, cmd ) ) return 0;
.

HTC

The whole problem is here:

PrivMessage(" Admin " + player.Name + " Set Money Of " + plr.Name + " To: " + mon + ".",player);

>>> + mon + <<<

[VSS]Shawn

Full Cmd Bug!
Noob function
PrivMessage

MacTavish

else if ( cmd =="setmon" )
{
if (!text) MessagePlayer("Syntax - /setmon <nick/id> <amount>",player);
else
{
local plr = GetPlayer( GetTok(text," ",1)), mon = GetTok(text," ",2);
if (!plr) MessagePlayer("Invalid Player",player);
else if (!mon) MessagePlayer("Money not specified",player);
else if (!IsNum(mon)) MessagePlayer("Money must be in number",player);
else
{
status[plr.ID].Cash += mon.tointeger();
player.Cash = status[plr.ID].Cash;
Message("Admin "+player.Name+" Has given "+mon+" $ to "+plr.Name+"");
}
}
}


Try it Untested

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

Thijn

@Beztone you obviously didn't test it, since you didn't define mon anywhere.

MacTavish

Quote from: Thijn on Jul 22, 2015, 05:50 AM@Beztone you obviously didn't test it, since you didn't define mon anywhere.

Ok i tested, its working

Grand Hunting Project
Join #SLC, #KAKAN, #Doom, #GHP @LUnet

Retired VC:MP Player/Scripter :P

Thijn

Quote from: Beztone on Jul 22, 2015, 06:09 AM
Quote from: Thijn on Jul 22, 2015, 05:50 AM@Beztone you obviously didn't test it, since you didn't define mon anywhere.

Ok i tested, its working
Oh of course, I misread that line.

HTC

Quote from: Beztone on Jul 22, 2015, 05:36 AMelse if ( cmd =="setmon" )
{
if (!text) MessagePlayer("Syntax - /setmon <nick/id> <amount>",player);
else
{
local plr = GetPlayer( GetTok(text," ",1)), mon = GetTok(text," ",2);
if (!plr) MessagePlayer("Invalid Player",player);
else if (!mon) MessagePlayer("Money not specified",player);
else if (!IsNum(mon)) MessagePlayer("Money must be in number",player);
else
{
status[plr.ID].Cash += mon.tointeger();
player.Cash = status[plr.ID].Cash;
Message("Admin "+player.Name+" Has given "+mon+" $ to "+plr.Name+"");
}
}
}


Try it Untested


Thanks, it worked!