Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (M_D), 1,430 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
[ANET] sending skills #402344
06/02/12 22:12
06/02/12 22:12
Joined: Apr 2005
Posts: 796
U.S.A. Michigan
exile Offline OP
User
exile  Offline OP
User

Joined: Apr 2005
Posts: 796
U.S.A. Michigan
Hey I was wondering if anyone had some code, or could show me how to send a skill of an entity created in wed? In short, I am trying to make a weapon pickup code and I am having some trouble. This is what I have so far...

Code:
function scan_event() 
{
	if (event_type == EVENT_SCAN) 
	{
		if(my.weaponToSpawn == 1 && my.weaponAmmoPickup > 0 && my.weaponPickup == 1)
		{
			weaponInventory[0] = 1;
			reloading = 0;
			reloadSfxOnce = 0;
			shootAnimationSpeed = 100;
			user.currentWeapon = 1;
			drawWeaponAnimation = 0;
			weaponReady = 0;
			snd_play(assaultDeploy,100*(sfxVolume/100),0);
			my.weaponPickup = 0;
			my.weaponRespawnTime = 100;
		}
	}
}

function spawnWeapon()
{
	set(my,PASSABLE);
	my.scale_x = 1.5;
	my.scale_y = my.scale_x;
	my.scale_z = my.scale_x;
	add_light(vector(my.x,my.y,my.z+10), vector(106,255,253), 20);
	my.material = glowShader;
	my.skill41 = floatv(0.02); // adjust the stength of the glow
	while(1)
	{
		my.pan += 5*time_step;
		wait(1);
	}
}

void weaponSpawnz()
{
	while(enet_ent_globpointer(my) == ANET_ERROR) {wait(1);} //wait until the entity gets a global pointer
	ENTITY* ent;
	var sendVarPickup = 0;
	my.emask |= ENABLE_SCAN;
	my.weaponRespawnTime = 0;
	my.weaponToSpawn = 1;
	my.weaponPickup = 0;
	set(my,PASSABLE|SHADOW);
	weaponSpawnerBaseEmitter();
	my.event = scan_event;
	if(my.weaponToSpawn == 1)
	{
		ent = ent_create("w_MK19.mdl", vector(my.x,my.y,my.z+40), spawnWeapon);
		my.weaponAmmoPickup = 30;
	}
	while(1)
	{
		if(my.weaponRespawnTime>0)
		{
			my.weaponRespawnTime-=1*time_step;
		}
		else
		{
			my.weaponRespawnTime = 0;
			my.weaponPickup = 1;
			sendVarPickup = 0;
		}
		if(my.weaponPickup == 0)
		{
			if(ent!=NULL && sendVarPickup == 0)
			{
				set(ent,INVISIBLE);
				enet_send_skills(enet_ent_globpointer(my),22,22,BROADCAST); 
				sendVarPickup = 1;
			}
		}
		else
		{
			if(ent!=NULL)
			{
				reset(ent,INVISIBLE);
			}
		}
		wait(1);
	}
}
//ent_create("placeholder.mdl",vector(0,0,0),weaponSpawnerFunc);
action weaponSpawnerFunc()
{
	set(my,PASSABLE|INVISIBLE);
	if(MY_CONNECTION == SERVER_MODE)
	{
		enet_svent_create(WEAPON_SPAWNER,vector(my.x,my.y,my.z));
	}
	else
	{
		enet_clent_create(WEAPON_SPAWNER,vector(my.x,my.y,my.z));
	}
}



I get a Bad Global Pointer error when I initiate the pickup script. So what am I doing wrong? Is there anyone who can help me figure this out?

What I am looking for is some way where...

- Player asks server "Hey can I pick this up?"
- Server says Yes or No based on whether THAT PARTICULAR weapon spawners "available" skill = 1;
- After the player has recieved the Yes/No, they take the appropriate action.


Last edited by exile; 06/03/12 09:56.
Re: [ANET] sending skills [Re: exile] #402364
06/03/12 12:27
06/03/12 12:27
Joined: Jul 2005
Posts: 1,930
Austria
Dark_samurai Offline
Serious User
Dark_samurai  Offline
Serious User

Joined: Jul 2005
Posts: 1,930
Austria
Sending skills is only possible for global entities. There once was a function you could use to "register" wed created entities (so that they got a global pointer) but that feature was removed in newer versions because it's not really needed.

For your weapon generator, you won't need to send skills if you do it the way I described it in the PM I've sent you.

But if you want to do it with skills, here is a small workaround:

In the action of the WED created entity, let the server (only the server!) create a global entity using enet_ent_create(). Then you can use this global entity as weapon generator.


ANet - A stable and secure network plugin with multi-zone, unlimited players, voip, server-list features,... (for A7/A8)!
get free version

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1