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

What am i doing wrong


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FlawlessKush
Member
Join Date: Mar 2014
Old 04-20-2015 , 00:54   What am i doing wrong
Reply With Quote #1

simple plugin that blocks respawning first 30 seconds of the round and it works but this fills my error logs I'm trying to get this to work on CSGO can you tell me whats wrong with this code?

Code:
public Action:RespawnPlayer(Handle:timer, any:client) 
{ 
    if (IsClientInGame(client)) 
    { 
        new team = GetClientTeam(client); 
        if (IsClientInGame(client) && (team == CS_TEAM_CT || team == CS_TEAM_T)) 
        { 
            CS_RespawnPlayer(client); 
        } 
    } 
}
FlawlessKush is offline
Darkness_
Veteran Member
Join Date: Nov 2014
Old 04-20-2015 , 01:03   Re: What am i doing wrong
Reply With Quote #2

Not quite; try something like this.

PHP Code:
someFunction(int client) {
    
CreateTimer(5.0RespawnPlayerGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
}

public 
Action RespawnPlayer(Handle timerany userId) {
    
int client GetClientOfUserId(userId);
    if (
client || client MaxClients) return Plugin_Stop;
    if (!
IsClientInGame(client)) return Plugin_Stop;
    if (
GetClientTeam(client) > 1)
        
CS_RespawnPlayer(client);
    return 
Plugin_Stop;

Darkness_ is offline
versatile_bfg
Veteran Member
Join Date: Feb 2012
Old 04-20-2015 , 01:45   Re: What am i doing wrong
Reply With Quote #3

Quote:
Originally Posted by Darkness_ View Post
Not quite; try something like this.

PHP Code:
someFunction(int client) {
    
CreateTimer(5.0RespawnPlayerGetClientUserId(client), TIMER_FLAG_NO_MAPCHANGE);
}

public 
Action RespawnPlayer(Handle timerany userId) {
    
int client GetClientOfUserId(userId);
    if (
client || client MaxClients) return Plugin_Stop;
    if (!
IsClientInGame(client)) return Plugin_Stop;
    if (
GetClientTeam(client) > 1)
        
CS_RespawnPlayer(client);
    return 
Plugin_Stop;

Just a question, why are you converting the client to userId in the createTimer then converting it back to client in the timer? Not saying it is wrong just wondering why? [more of a learning question].
__________________
versatile_bfg is offline
Darkness_
Veteran Member
Join Date: Nov 2014
Old 04-20-2015 , 02:04   Re: What am i doing wrong
Reply With Quote #4

Quote:
Originally Posted by versatile_bfg View Post
Just a question, why are you converting the client to userId in the createTimer then converting it back to client in the timer? Not saying it is wrong just wondering why? [more of a learning question].
Client indexes reused and client userIds are constant.
Darkness_ is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 04-20-2015 , 09:11   Re: What am i doing wrong
Reply With Quote #5

A more in depth explanation of this:

If a client disconnects while the timer is going, it's possible for a new client to connect and get the client index of of the player that just disconnected.

So, normally you'll want to pass either the client userid or serial.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 04-20-2015 , 09:51   Re: What am i doing wrong
Reply With Quote #6

And ofc (next time) post your error log here. It can help a lot to find a problem.

Last edited by KissLick; 04-20-2015 at 09:52.
KissLick 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 18:15.


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