This topic was marked solved by its starter, on June 20th, 2016, 10:14 AM

vito

  • Sr. Member
  • Posts: 405

EK.IceFlake

  • Hero Member
  • "We are the champions my fellahs" - Sufyan/VK.SuFy
  • Posts: 1,761

Xmair

  • Wiki Contributor
  • Posts: 952

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

KAKAN

  • Wiki Contributor
  • Posts: 3,343
oh no

vito

  • Sr. Member
  • Posts: 405
Re: how to add method to datatype, really how
« Reply #4, on June 20th, 2016, 10:14 AM »
Thanks guys. All works fine.
Code: [Select]
function CPlayer::sethp( val )
{
this.Health = val;
::MessagePlayer("Your HP now is "+ val, this );
MessagePlayer();
}

function CPlayer::MessagePlayer()
{
::MessagePlayer("I'm in this class too", this );
}

Code: [Select]
function onPlayerCommand( player, cmd, text )
{
if(cmd == "sethp"){
player.sethp( text.tointeger() );
}
}

Code: [Select]
function onPlayerEnterVehicle( player, vehicle, door ){
vehicle.Up();
}

Code: [Select]
function CVehicle::Up()
{
this.Pos.z = this.Pos.z + 5;
}
Re: how to add method to datatype, really how
« Reply #5, on July 28th, 2016, 07:23 PM »
I will re-open this topic and bump it to make one more question.
Is it possible to add methods to string/array/table/integer objects?

.

  • VC:MP Beta Tester
  • .
  • Posts: 1,808
.

vito

  • Sr. Member
  • Posts: 405

.

  • VC:MP Beta Tester
  • .
  • Posts: 1,808
Re: how to add method to datatype, really how
« Reply #8, on July 28th, 2016, 07:59 PM »
The only way I can think of is to modify the Squirrel source. I don't think the primitive types can be altered by any third-party code/plugin/module/library w/e.
.

KAKAN

  • Wiki Contributor
  • Posts: 3,343
Re: how to add method to datatype, really how
« Reply #9, on July 29th, 2016, 09:32 AM »
Quote from vito on July 28th, 2016, 07:23 PM
I will re-open this topic and bump it to make one more question.
Is it possible to add methods to string/array/table/integer objects?
I always wanted that, but, you can't do it without editing the source :(
But, you can make another class for string/table/... manipulation though :p
oh no