PDA

View Full Version : Grabbing of floor?


Knightmare1
12-29-2007, 05:24 AM
is there a way to do add items (guns, items, etc.) that are lying on the ground? would i have to make it like this? and so it dissapears.
//#CLIENTSIDE
function onActionGrab() {
clientr.weapon.? = 1;
destroy;
}

Codein
12-29-2007, 05:35 AM
is there a way to do add items (guns, items, etc.) that are lying on the ground? would i have to make it like this? and so it dissapears.
//#CLIENTSIDE
function onActionGrab() {
clientr.weapon.? = 1;
destroy;
}

You'd need to make your own Grab trigger. Also, clientr. flags can't be set clientside.

Angel_Light
12-29-2007, 06:41 AM
function onKeyPressed( code, key)
{

switch ( temp.code)
{

case "65": //a
Grab();
break;

}
}

function Grab()
{

frontPosition = { player.x + 1.5 + vecx(player.dir) * 2, player.y + 1.5 + vecy(player.dir) * 2};

canGrab = ( testplayer(frontPosition[0], frontPosition[1]) || testnpc(frontPosition[0], frontPosition[1]));

if ( canGrab)
triggerAction(frontPosition[0], frontPosition[1], "Grabbed", player.account, player.guild);

}

Here what I use, forgot where I got it though. :/

coreys
12-29-2007, 06:59 AM
You'd need to make your own Grab trigger. Also, clientr. flags can't be set clientside.
Not...ENTIRELY true...

Angel_Light
12-29-2007, 07:09 AM
Not...ENTIRELY true...

please do explain, I know client.vars can be set both and I thought clientr.vars could only be set serverside, for security. :/

coreys
12-29-2007, 07:28 AM
You can...sort of set clientr vars clientside
but I think it it acts more like a public variable (a.k.a. without a heading like this. or temp.) that happens to start with "clientr," therefore effectively replacing a real one that may exist.

Anyways, it really is best to use triggeractions for this...

Codein
12-29-2007, 04:15 PM
You can...sort of set clientr vars clientside
but I think it it acts more like a public variable (a.k.a. without a heading like this. or temp.) that happens to start with "clientr," therefore effectively replacing a real one that may exist.

Anyways, it really is best to use triggeractions for this...

In the way that he's using clientr. variables, I think he'd want to set them serverside. Either way, even if you can or can't, it'd just be best for him to set them serverside.

cbk1994
12-29-2007, 04:36 PM
destroy() not destroy;

Knightmare1
12-29-2007, 06:31 PM
function onKeyPressed( code, key)
{

switch ( temp.code)
{

case "65": //a
Grab();
break;

}
}

function Grab()
{

frontPosition = { player.x + 1.5 + vecx(player.dir) * 2, player.y + 1.5 + vecy(player.dir) * 2};

canGrab = ( testplayer(frontPosition[0], frontPosition[1]) || testnpc(frontPosition[0], frontPosition[1]));

if ( canGrab)
triggerAction(frontPosition[0], frontPosition[1], "Grabbed", player.account, player.guild);

}

Here what I use, forgot where I got it though. :/ would that be for the system script? or the item script?

xXziroXx
12-29-2007, 06:56 PM
If that's what you're gonna use, it should be clientsided in a system NPC.

coreys
12-29-2007, 07:00 PM
In the way that he's using clientr. variables, I think he'd want to set them serverside. Either way, even if you can or can't, it'd just be best for him to set them serverside.

Oh, well yeah, I know.

cbk1994
12-29-2007, 08:04 PM
I thought clientr. variables had to be set serverside? Or am I totally wrong?

Either way, I would set something like that serverside.

Knightmare1
12-29-2007, 10:05 PM
and in that script that angel made, what would i edit to make it show an icon?

Angel_Light
12-29-2007, 10:25 PM
well thats part of a system weapon. For Instance you add this to a weapon.


//#CLIENTSIDE
function onKeyPressed( code, key)
{

switch ( temp.code)
{

case "65": //a
Grab();
break;

}
}

function Grab()
{

frontPosition = { player.x + 1.5 + vecx(player.dir) * 2, player.y + 1.5 + vecy(player.dir) * 2};

canGrab = ( testplayer(frontPosition[0], frontPosition[1]) || testnpc(frontPosition[0], frontPosition[1]));

if ( canGrab)
triggerAction(frontPosition[0], frontPosition[1], "Grabbed", player.account, player.guild);

}


then in a level NPC on the ground you would add this.



function onCreated()
{

setImg( image);
setShape( 1, 16*2, 16*2);

}

function onActionGrabbed()
{

findPlayer( params[ 0]).addWeapon( weapon);

destroy();

}

Knightmare1
12-30-2007, 02:18 AM
function onCreated()
{

setImg(this.image);
setShape( 1, 16*2, 16*2);

}

function onActionGrabbed()
{

findPlayer( params[ 0]).addWeapon( weapon);

destroy();

} could i make the image this.image = "image" in the NPC? im using classes.

cbk1994
12-30-2007, 02:49 AM
That script needs some work (I would add logging, etc, and checks to make sure it hasn't already been picked up but not destroyed for some reason.

However, I would do something like

setImg( this.img );

and then


temp.n = putnpc2( temp.dx, temp.dy, "" );
with ( temp.n )
{
join( "object_dropitem" );
this.img = "block.png";
this.weapon = "Staff/Abuse/Major/Bloo/Tool"; // shout-out to Bloo
}

Knightmare1
12-30-2007, 04:48 AM
That script needs some work (I would add logging, etc, and checks to make sure it hasn't already been picked up but not destroyed for some reason.

However, I would do something like

setImg( this.img );

and then


temp.n = putnpc2( temp.dx, temp.dy, "" );
with ( temp.n )
{
join( "object_dropitem" );
this.img = "block.png";
this.weapon = "Staff/Abuse/Major/Bloo/Tool"; // shout-out to Bloo
}


temp.n = putnpc2( temp.dx, temp.dy, "" );
with ( temp.n )
{
join( "object_flooritem" );
this.img = "final_ak47-icon.gif";
this.weapon = "Guns/AK47";
}
would that work?

cbk1994
12-30-2007, 05:35 AM
temp.n = putnpc2( temp.dx, temp.dy, "" );
with ( temp.n )
{
join( "object_flooritem" );
this.img = "final_ak47-icon.gif";
this.weapon = "Guns/AK47";
}
would that work?

Yes, the code you posted earlier had addweapon( weapon ); just change that to addweapon( this.weapon );

Knightmare1
12-30-2007, 07:30 AM
Yes, the code you posted earlier had addweapon( weapon ); just change that to addweapon( this.weapon );

dam chris, you've done it again. ^^
and is there a way to randomize spawn points once picked up? like
setlevel2( "final_gmap.gmap", randomize(1,200), randomize(1,200) );
would this work?

cbk1994
12-30-2007, 05:21 PM
I would get rid of the destroy() and add a hide, then sleep, then warp it, and show it.

As for warping it, this.x = random( 0, 200 ) and the same for y. I'll give an example when I get home, hard to script on a phone.

DustyPorViva
12-30-2007, 05:46 PM
dam chris, you've done it again. ^^
and is there a way to randomize spawn points once picked up? like
setlevel2( "final_gmap.gmap", randomize(1,200), randomize(1,200) );
would this work?

temp.spawnpoints={{1,5},{8,2},{9,1},{12,62},{12,6} ,{15,73},{51,52}};
temp.random=int(random(0,temp.spawnpoints.size());
setlevel2("final_gmap.gmap",temp.spawnpoints[temp.random][0],temp.spawnpoints[temp.random][1]);

coreys
12-30-2007, 06:05 PM
Actually, Dusty, temp.random should just be int(random(0,temp.spawnpoints.size()));
shouldn't it? o.0

Knightmare1
12-30-2007, 06:12 PM
function onCreated()
{

setImg( this.img );
setShape( 1, 16*2, 16*2 );
temp.spawnpoints={{ 1,5 },{ 8,2 },{ 9,1 },{ 12,62 },{ 12,6 },{ 15,73 },{ 51,52 }};
temp.random=int(random(0,temp.spawnpoints.size()+1 );

}

function onActionGrabbed()
{

findPlayer( params[ 0] ).addWeapon( this.weapon );
hide;
sleep(540);
setlevel2("final_gmap.gmap",temp.spawnpoints[temp.random][0],temp.spawnpoints[temp.random][1]);
show;
} would this work?

DustyPorViva
12-30-2007, 06:14 PM
That it should be... I think... my mind isn't processing so I'm having a hard time double checking if it's right or wrong. I'll go ahead and say you're right.

And no, that won't work. temp. is only accessible in the function it's called in. You're gonna have to change that temp. to a this.

Knightmare1
12-30-2007, 06:17 PM
function onCreated()
{

setImg( this.img );
setShape( 1, 16*2, 16*2 );
this.spawnpoints={{ 1,5 },{ 8,2 },{ 9,1 },{ 12,62 },{ 12,6 },{ 15,73 },{ 51,52 }};
this.random=int(random(0,this.spawnpoints.size()+1 ));

}

function onActionGrabbed()
{

findPlayer( params[ 0] ).addWeapon( this.weapon );
hide;
sleep(540);
setlevel2("final_gmap.gmap",this.spawnpoints[this.random][0],this.spawnpoints[this.random][1]);
show;
}

/*The script for NPC.

temp.n = putnpc2( temp.dx, temp.dy, "" );
with ( temp.n )
{

join( "flooritem" );
this.img = "icon.type";
this.weapon = "Weapon/Name";

}

*/ this works?

cbk1994
12-30-2007, 08:26 PM
no. setlevel2 is for warping players. Use this.x and this.y

Knightmare1
12-30-2007, 08:28 PM
no. setlevel2 is for warping players. Use this.x and this.y

what about setting the level?

coreys
12-30-2007, 09:04 PM
Hmm, I...think you can do that with setting this.level. I'm not entirely sure, though. I've never really tried it.

cbk1994
12-30-2007, 11:42 PM
Hmm, I...think you can do that with setting this.level. I'm not entirely sure, though. I've never really tried it.

Nope. setlevel( name ); for npcs. Still need to set x and y.

Inverness
12-31-2007, 03:54 AM
To warp an npc you would use warpto(levelname, x, y);

Knightmare1
01-05-2008, 06:58 PM
function onCreated()
{

setImg( this.img );
setShape( 1, 16*2, 16*2 );
this.spawnpoints={{ 1,5 },{ 8,2 },{ 9,1 },{ 12,62 },{ 12,6 },{ 15,73 },{ 51,52 }};
this.random=int(random(0,this.spawnpoints.size()+1 ));

}

function onActionGrabbed()
{

findPlayer( params[ 0] ).addWeapon( this.weapon );
hide;
sleep(540);
warpto("final_gmap.gmap",this.spawnpoints[this.random][0],this.spawnpoints[this.random][1]);
show;
}

so this?

Chompy
01-05-2008, 08:46 PM
have you tried it? :p

Knightmare1
01-05-2008, 08:53 PM
have you tried it? :pnope, because i have no graphics yet.

Chompy
01-05-2008, 09:28 PM
nope, because i have no graphics yet.

use "block.png" ;)

Knightmare1
01-07-2008, 02:01 AM
use "block.png" ;) i did, it wont work.

Chompy
01-07-2008, 10:54 PM
i did, it wont work.

what didn't work? adding the weapon? we-appearing some where on a gmap?

Knightmare1
01-07-2008, 11:03 PM
what didn't work? adding the weapon? we-appearing some where on a gmap?
LOL i tried to use it on my OSL.

Chompy
01-07-2008, 11:15 PM
LOL i tried to use it on my OSL.

What the ..? You didn't state that anywhere did you? Because of what you said, it seems that you aren't using the script that you posted some posts earlier..

And you don't give info at all, do you? Sorry, can't help you.

projectigi
01-07-2008, 11:48 PM
function onCreated()
{

setImg( this.img );
setShape( 1, 16*2, 16*2 );
this.spawnpoints={{ 1,5 },{ 8,2 },{ 9,1 },{ 12,62 },{ 12,6 },{ 15,73 },{ 51,52 }};
this.random=int(random(0,this.spawnpoints.size()+1 ));

}

function onActionGrabbed()
{

findPlayer( params[ 0] ).addWeapon( this.weapon );
hide;
sleep(540);
warpto("final_gmap.gmap",this.spawnpoints[this.random][0],this.spawnpoints[this.random][1]);
show;
}

so this?

uh well, either its an npc(warpto()) or its a weapon( addWeapon( this.weapon ) ); or what you set @ this.weapon? xD

cbk1994
01-08-2008, 12:57 AM
Night, I'll help you with this whenever we're both on if you like.

Post your code.

Knightmare1
01-08-2008, 04:47 AM
its still not working. and for some odd reason neither are my tiles...

here is code:
function onCreated()
{

setImg( this.img );
setShape( 1, 16*2, 16*2 );
this.spawnpoints={{ 1,5 },{ 8,2 },{ 9,1 },{ 12,13 },{ 12,6 },{ 15,43 },{ 51,52 }};
this.random=int(random(0,this.spawnpoints.size()+1 ));

}

function onActionGrabbed()
{

findPlayer( params[ 0] ).addWeapon( this.weapon );
hide;
sleep(540);
warpto("final_osl.nw",this.spawnpoints[this.random][0],this.spawnpoints[this.random][1]);
show;
}

/*The script for NPC.

temp.n = putnpc2( temp.dx, temp.dy, "" );
with ( temp.n )
{

join( "flooritem" );
this.img = "icon.type";
this.weapon = "Weapon/Name";

}

*/
code for system weapon:
//#CLIENTSIDE
function onKeyPressed( code, key)
{

switch ( temp.code)
{

case "65": //a
Grab();
break;

}
}

function Grab()
{

frontPosition = { player.x + 1.5 + vecx(player.dir) * 2, player.y + 1.5 + vecy(player.dir) * 2};

canGrab = ( testplayer(frontPosition[0], frontPosition[1]) || testnpc(frontPosition[0], frontPosition[1]));

if ( canGrab)
triggerAction(frontPosition[0], frontPosition[1], "Grabbed", player.account, player.guild);
}

Chompy
01-08-2008, 04:35 PM
in the script for the npc, is temp.dx, temp.dy setted? if not the item will be placed on 0,0..