[FilterScript] Spectating System
#1

Spectating System
Description

Brings the ability to attend as a spectator in SA-MP.

Commands

1. /spec
2. /specoff

Download

https://github.com/KevinMarapao/Spectating-System
Reply
#2

Simple, as i see ur new, good attempts mate!
Reply
#3

Why to hook a filterscript?

Код:
stock Hook_LinkVehicleToInterior(vehicleid, interiorid)
{
	vhInterior[vehicleid] = interiorid;
	return LinkVehicleToInterior(vehicleid, interiorid);
}

#if defined _ALS_LinkVehicleToInterior
	#undef LinkVehicleToInterior
#else
	#define _ALS_LinkVehicleToInterior
#endif
#define LinkVehicleToInterior Hook_LinkVehicleToInterior
Reply
#4

O.O, Simple but nice D:, Keep the good work .
Reply
#5

Quote:
Originally Posted by [ND]xXZeusXx.
Посмотреть сообщение
Simple, as i see ur new, good attempts mate!
I don't want to create anything big and fancy at the moment, I'm just releasing scripts people have asked for or requested help on a script in exact relation in order to give them a little hand.

Plus, a virtual date has nothing to do with one's knowledge. You could be an oldie and know nothing, wouldn't make a difference. Not to mention that I have been registered here longer than you in other instants, but hey, thanks!

Quote:
Originally Posted by SecretBoss
Посмотреть сообщение
Why to hook a filterscript?

Код:
stock Hook_LinkVehicleToInterior(vehicleid, interiorid)
{
	vhInterior[vehicleid] = interiorid;
	return LinkVehicleToInterior(vehicleid, interiorid);
}

#if defined _ALS_LinkVehicleToInterior
	#undef LinkVehicleToInterior
#else
	#define _ALS_LinkVehicleToInterior
#endif
#define LinkVehicleToInterior Hook_LinkVehicleToInterior
It's a hooked function. It does the exact same thing as the default function but stores the new interior id of the vehicle in a variable, making it possible to create a function such as "GetVehicleInteriorID();" as it is needed for the script and does not exist by default.
Reply
#6

Quote:
Originally Posted by Kevln
Посмотреть сообщение
I don't want to create anything big and fancy at the moment, I'm just releasing scripts people have asked for or requested help on a script in exact relation in order to give them a little hand.

Plus, a virtual date has nothing to do with one's knowledge. You could be an oldie and know nothing, wouldn't make a difference. Not to mention that I have been registered here longer than you in other instants, but hey, thanks!



It's a hooked function. It does the exact same thing as the default function but stores the new interior id of the vehicle in a variable, making it possible to create a function such as "GetVehicleInteriorID();" as it is needed for the script and does not exist by default.
Hmmm, you can do it and with other methods but its ok, each one has his own way of scripting
Reply
#7

Quote:
Originally Posted by SecretBoss
Посмотреть сообщение
Hmmm, you can do it and with other methods but its ok, each one has his own way of scripting
Other methods? How exactly?
Reply
#8

Quote:
Originally Posted by Kevln
Посмотреть сообщение
Plus, a virtual date has nothing to do with one's knowledge. You could be an oldie and know nothing, wouldn't make a difference. Not to mention that I have been registered here longer than you in other instants, but hey, thanks!
Yep, sick!
----

I like the way you code things. Keep up the good work!
Reply
#9

Quote:
Originally Posted by Kevln
Посмотреть сообщение
Other methods? How exactly?
You can do it with LinkVehicleToInterior
Reply
#10

nice. and simple
Reply
#11

@SecretBoss & Gammix: Both of your statements make no-sense.

The whole point in hooking "LinkVehicleToInterior()" is to be able to use the native function while allowing extra executions to be performed at the same instance, and without having to edit existent usages of the function itself. In this case, it's saving the vehicle's interior ID in a variable then linking the vehicle to the specified interior ID (by returning the native function and not the hook), so that we can create a new function that returns the vehicle's interior ID (GetVehicleInteriorID()) as it is needed when a player spectates a player that's driving a vehicle.

In brief, you don't use "Hook_LinkVehicleToInterior()", but "LinkVehicleToInterior()".

I added a note to the main post.

Thanks guys.
Reply
#12

Nevermind, but you didn't understand that you can directly use Hook_LinkVehicleToInterior instead of hooking.

But, i wonder why would anyone check for vehicle interior ids, if the spectate system is based on players. What happens if i change the interiorid from my gamemode, your hooking is just trash. You don't need to store vehicles interiorids but only use GetPlayerInterior and OnPlayerInteriorChange.
Reply
#13

Quote:
Originally Posted by Gammix
Посмотреть сообщение
Nevermind, but you didn't understand that you can directly use Hook_LinkVehicleToInterior instead of hooking.

But, i wonder why would anyone check for vehicle interior ids, if the spectate system is based on players. What happens if i change the interiorid from my gamemode, your hooking is just trash. You don't need to store vehicles interiorids but only use GetPlayerInterior and OnPlayerInteriorChange.
Hook_LinkVehicleToInterior nor LinkVehicleToInterior is used in the filterscript, and whether Hook_LinkVehicleToInterior or LinkVehicleToInterior is used, it wouldn't make a difference, both do the same thing in the filterscript.

I thought it would be better to get the vehicle's interior ID as sometimes people set their vehicle in another interior to make the vehicle invisible, but as the hook cannot be set to work in a filterscript and a gamemode at the same time (without remote calling), I updated the code to use your suggestion.

I also added some other things. But in all intentions, I didn't want to make something complete out of this. I am more of a guy that wants others to try, meaning that I tend to create script-bases more often than giving people everything done when it comes to helping others.

I created this for a guy in the scripting help section and just thought I'd release it here. It's very simple, but if one needs it, another one might need it too.

Thank you.
Reply
#14

You don't stop or advance spectate when the player disconnects, dies.

You would also require to check for virtual worlds, and that would require you to make checks under OnPlayerUpdate (for script compatibility with others).

There are several more things a spectate system should have, but since you script basics, i won't argue on this.
Reply
#15

Quote:
Originally Posted by Gammix
Посмотреть сообщение
You don't stop or advance spectate when the player disconnects, dies.

You would also require to check for virtual worlds, and that would require you to make checks under OnPlayerUpdate (for script compatibility with others).

There are several more things a spectate system should have, but since you script basics, i won't argue on this.
I couldn't care less about those things, if people want them then they would have to work for it. It's just a base to get people started.

We have two completely different points of views towards releases. I don't see the benefit in plug-and-play scripts.
Reply
#16

Quote:
Originally Posted by Kevln
Посмотреть сообщение
I couldn't care less about those things, if people want them then they would have to work for it. It's just a base to get people started.

We have two completely different points of views towards releases. I don't see the benefit in plug-and-play scripts.
Well, I don't know about you, but when I am releasing something I know that too many newbies will use it for their scripts or other things so I am trying my best to make it more advance, there are a lot of people who are still learning developing scripts and they can't update/understand the scripts so they can't do anything with your script
Reply
#17

Simple,and nice.
Reply
#18

Quote:
Originally Posted by SecretBoss
Посмотреть сообщение
Well, I don't know about you, but when I am releasing something I know that too many newbies will use it for their scripts or other things so I am trying my best to make it more advance, there are a lot of people who are still learning developing scripts and they can't update/understand the scripts so they can't do anything with your script
I'm doing this for educational purposes (a script that someone needed in the scripting help section, to just get them started), I honestly don't see the point in just inserting things on a server that's online and live happily ever after.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)