Vice City: Multiplayer

Server Development => Scripting and Server Management => Topic started by: kokia on Oct 16, 2015, 07:50 AM

Title: arith op
Post by: kokia on Oct 16, 2015, 07:50 AM
hello guys plzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz help me there is a problem
reg function error : arith op + between "null" and "integer" plzzzzzzzzzzzzzzz help help help
code :
function Register( player, password )
{
     try{
local pass = SHA256(password);
QuerySQL( db, "INSERT INTO Account ( Name, UID, Level, Pass, Cash, Kills, Deaths ) VALUES ( '" + player.Name.tolower() + "', '" + player.UniqueID + "', '1', '" + pass + "', '0', '0', '0' )" );
status[ player.ID ].IsLogged = true;
status[ player.ID ].IsReg = true;
  local q = QuerySQL(db,"SELECT Cash FROM Accounts WHERE Name='"+player.Name+"'")
  status[player.ID].Cash=GetSQLColumnData(q,0)
  status[player.ID].Kills=GetSQLColumnData(q,1)
  status[player.ID].Deaths=GetSQLColumnData(q,2)
IncCash(player,5000)
ServerMessage( "You've successfully registered with the password " + password, player );
}
catch(e) print( "Reg Function Error: " + e );
}
error on inccash i give :
function IncCash( player, amount )
{
      local cash = status[ player.ID ].Cash;
  local add = cash + amount;
  status[ player.ID ].Cash = add;
  player.Cash = add;
}
Title: Re: arith op
Post by: SAzEe21 on Oct 16, 2015, 08:01 AM
Post the screenshots. Of errors.
Title: Re: arith op
Post by: KAKAN on Oct 16, 2015, 08:35 AM
use this:-
function IncCash( player, amount )
{
      local cash = status[ player.ID ].Cash;
   local add = cash + amount.tointeger();
   status[ player.ID ].Cash = add;
   player.Cash = add;
}
If it doesn't works, remove the try-catch blocks and tell us the error line.
Title: Re: arith op
Post by: kokia on Oct 16, 2015, 09:11 AM
doesnt works
removed try catch
prob is continueing
line 305 :    local add = cash + amount.tointeger();
line 1335 :     IncCash(player,5000)
line 422 :       else Register(player,text)
Title: Re: arith op
Post by: Mashreq on Oct 16, 2015, 10:18 AM
Try using this:
function Register( player, password )
{
     try{
  local pass = SHA256(password);
  QuerySQL( db, "INSERT INTO Account ( Name, UID, Level, Pass, Cash, Kills, Deaths ) VALUES ( '" + player.Name.tolower() + "', '" + player.UniqueID + "', '1', '" + pass + "', '0', '0', '0' )" );
  status[ player.ID ].IsLogged = true;
  status[ player.ID ].IsReg = true;
      local q = QuerySQL(db,"SELECT Cash, Kills, Deaths FROM Accounts WHERE Name='"+player.Name.tolower()+"'");
     if ( GetSQLColumnData(q, 0 ) )
    {
    status[player.ID].Cash=GetSQLColumnData(q,0);
    status[player.ID].Kills=GetSQLColumnData(q,1);
    status[player.ID].Deaths=GetSQLColumnData(q,2);
    }
   FreeSQLQuery( q );
  IncCash( player,5000 );
  ServerMessage( "You've successfully registered with the password " + password, player );
  }
  catch(e) print( "Reg Function Error: " + e ); 
}
Title: Re: arith op
Post by: kokia on Oct 16, 2015, 10:27 AM
error is still  coming @Mashreq help plaese
Title: Re: arith op
Post by: Mashreq on Oct 16, 2015, 10:32 AM
Try using this function for Increasing the player's cash
function IncCash( player, amount )
{
      local cash = status[ player.ID ].Cash;
   local add = cash.tointeger() + amount.tointeger();
   status[ player.ID ].Cash = add;
   player.Cash = add;
}
Title: Re: arith op
Post by: . on Oct 17, 2015, 01:44 PM
pooooooooooooop, hello, poop, function poop, give poop and help, help, help, poop cash poop error poop... That's all I see there.

But my suggestion:
print(null + 3);
Quite obvious isn't it?