Raised This Month: $51 Target: $400
 12% 

[L4D & L4D2] ESPer Tank (1.2) [2020/Jan/22nd]


Post New Thread Reply   
 
Thread Tools Display Modes
Silvers
SourceMod Plugin Approver
Join Date: Aug 2010
Location: SpaceX
Old 01-16-2020 , 11:29   Re: [L4D & L4D2] ESPer Tank (1.1) [2020/Jan/17th]
Reply With Quote #11

Change:
PHP Code:
    int tank GetClientOfUserId(g_tank);
    if(!
IsClientInGame(tank)) return; 
To:
PHP Code:
    int tank GetClientOfUserId(g_tank); // Returns 0 when the client no longer exists.
    
if(!g_tank || !IsClientInGame(tank)) return; // IsClientInGame(0) errors with "Client index 0 is invalid" on dedicated servers, validate g_tank is not 0 first.
    // I actually think the IsClientInGame check might not be needed here because the client serial is already validated by not being 0. 
Everywhere you have this, replace with the above check:
PHP Code:
    int tank GetClientOfUserId(g_tank); // GetClientOfUserId returns 0 when invalid.
    
if(IsValidEdict(tank)) // IsValidEdict(0) will return true because the server 0 is valid. Also IsValidEdict is for entities not clients. 

EntIndexToEntRef - "Converts an entity index into a serial encoded entity reference."

EntRefToEntIndex - Retrieves the entity index from a reference.

You must use EntIndexToEntRef when storing entity indexes or putting them in a timer and EntRefToEntIndex when retrieving later. Otherwise you run the risk of affecting the wrong entity. Using EntIndexToEntRef makes a unique ID for the entity, allowing you to validate later that you're affecting the actual entity you intended.



The same must be done with clients, or you run the risk of affecting the wrong client because they disconnected:

GetClientUserId - "Retrieves a client's user id, which is an index incremented for every client that joins the server."

GetClientOfUserId - "Translates an userid index to the real player index."
__________________

Last edited by Silvers; 01-16-2020 at 11:31.
Silvers is offline
spike1234
Junior Member
Join Date: Jun 2019
Location: Japan
Old 01-19-2020 , 06:35   Re: [L4D & L4D2] ESPer Tank (1.1) [2020/Jan/17th]
Reply With Quote #12

Oooh... I'm getting confused little bit.

I have a question about this.
Quote:
Originally Posted by Silvers View Post
To:
PHP Code:
    int tank GetClientOfUserId(g_tank); // Returns 0 when the client no longer exists.
    
if(!g_tank || !IsClientInGame(tank)) return; // IsClientInGame(0) errors with "Client index 0 is invalid" on dedicated servers, validate g_tank is not 0 first.
    // I actually think the IsClientInGame check might not be needed here because the client serial is already validated by not being 0. 
It isn't this?
PHP Code:
int tank GetClientOfUserId(g_tank);
if(!
tank || !IsClientInGame(tank)) return; 
If use !g_tank to prevent get error on IsClientInGame(0), I think it should use tank not g_tank.

At first g_tank stores tank's id when tank used ability, and never get value bigger than 0.
hence g_tank never be 0.

Edit:
I noticed that if tank uses ability after other tank floated rocks,
I think those rocks may be fly to place where the last tank used ability is aiming...
How do i solve this?
__________________

My first language is not English.
So I would be grateful if you correct my sentences if I wrote something wrong.
I'm not active recently, sorry.

Last edited by spike1234; 01-19-2020 at 13:28.
spike1234 is offline
spike1234
Junior Member
Join Date: Jun 2019
Location: Japan
Old 01-27-2020 , 08:13   Re: [L4D2] ESPer Tank v1.0
Reply With Quote #13

Quote:
Originally Posted by Marttt View Post
Amazing!

I had a similar idea (never implemented),
I wanted to create a tornado of rocks around the tank, and then randomly send the rocks in direction of the client.
So the survivors would have to destroy the rocks first to hit the tank.

I never make it, but your plugin is very close
Hmmm... sounds technically hard but so interesting.
__________________

My first language is not English.
So I would be grateful if you correct my sentences if I wrote something wrong.
I'm not active recently, sorry.

Last edited by spike1234; 01-27-2020 at 08:14.
spike1234 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:43.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode