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

[CS GO][Help] Client timer and Positions


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dr.Mohammad
Senior Member
Join Date: Jan 2016
Location: CSGO Servers
Old 11-28-2018 , 04:20   [CS GO][Help] Client timer and Positions
Reply With Quote #1

hi guys!
how to i can add createtimer for every client??

this not work:
PHP Code:
#include <sourcemod> 
#include <cstrike>
#include <clientprefs>
#include <sdktools>

#pragma semicolon 1
#pragma newdecls required

float positions[MAXPLAYERS 1][3];

public 
void OnPluginStart()
{
    
HookEvent("round_poststart"Event_RoundStart);
}

public 
Action Event_RoundStart(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));

    if (
client && client <= MaxClients)
    {
        
CreateTimer(3.0GetPositions,  GetClientSerial(client));
    }
    return 
Plugin_Handled;
}

public 
Action GetPositions(Handle timerany serial)
{
    
int client GetClientFromSerial(serial);

    if(
client && client <= MaxClients && GetClientTeam(client) != CS_TEAM_SPECTATOR && IsClientInGame(client) && IsPlayerAlive(client) && !IsFakeClient(client) && !IsClientSourceTV(client))
    {
        
GetClientEyePosition(clientpositions[client]);
        
PrintToChat(client"[position] Your Positions: [%d] [%d] [%d]"positions[client][0], positions[client][1], positions[client][2])
    }
    return 
Plugin_Stop;


Last edited by Dr.Mohammad; 11-28-2018 at 04:21.
Dr.Mohammad is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 11-28-2018 , 04:48   Re: [CS GO][Help] Client timer and Positions
Reply With Quote #2

You already are
__________________
8guawong is offline
eyal282
Veteran Member
Join Date: Aug 2011
Old 11-28-2018 , 05:44   Re: [CS GO][Help] Client timer and Positions
Reply With Quote #3

Try the event round_start
__________________
I am available to make plugins for pay.

Discord: Eyal282#1334
eyal282 is offline
Dr.Mohammad
Senior Member
Join Date: Jan 2016
Location: CSGO Servers
Old 11-28-2018 , 05:59   Re: [CS GO][Help] Client timer and Positions
Reply With Quote #4

Quote:
Originally Posted by eyal282 View Post
Try the event round_start
i tried again
but not work.

Dr.Mohammad is offline
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 11-28-2018 , 06:09   Re: [CS GO][Help] Client timer and Positions
Reply With Quote #5

If you create timers in round start and you don't delete them in round end, then your server will crash.
Also, the round_start (any round_ event) doesn't have the "userid" param.

PHP Code:

public Action Event_RoundStart(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"userid")); // here is your error, userid param doesn't exist for round_ events

    
if (client && client <= MaxClients)
    {
        
CreateTimer(3.0GetPositions,  GetClientSerial(client));
    }
    return 
Plugin_Handled;

Create a timer in OnMapStart():

PHP Code:

public void OnMapStart()
{
    
CreateTimer(3.0Timer_Positions_TIMER_REPEAT TIMER_FLAG_NO_MAPCHANGE);
}


public 
Action Timer_Positions(Handle timerany data)
{
    for (
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && GetClientTeam(i) > && IsPlayerAlive(i))
        {
                
GetClientEyePosition(ipositions[client]);
        }
    }


Last edited by Ilusion9; 11-28-2018 at 06:10.
Ilusion9 is offline
Dr.Mohammad
Senior Member
Join Date: Jan 2016
Location: CSGO Servers
Old 11-28-2018 , 10:35   Re: [CS GO][Help] Client timer and Positions
Reply With Quote #6

Quote:
Originally Posted by Ilusion9 View Post
If you create timers in round start and you don't delete them in round end, then your server will crash.
Also, the round_start (any round_ event) doesn't have the "userid" param.

PHP Code:

public Action Event_RoundStart(Event event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"userid")); // here is your error, userid param doesn't exist for round_ events

    
if (client && client <= MaxClients)
    {
        
CreateTimer(3.0GetPositions,  GetClientSerial(client));
    }
    return 
Plugin_Handled;

Create a timer in OnMapStart():

PHP Code:

public void OnMapStart()
{
    
CreateTimer(3.0Timer_Positions_TIMER_REPEAT TIMER_FLAG_NO_MAPCHANGE);
}


public 
Action Timer_Positions(Handle timerany data)
{
    for (
int i 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && GetClientTeam(i) > && IsPlayerAlive(i))
        {
                
GetClientEyePosition(ipositions[client]);
        }
    }

all right, thank you but i need timer for every round, you have any idea??
Dr.Mohammad is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 11-28-2018 , 11:43   Re: [CS GO][Help] Client timer and Positions
Reply With Quote #7

...in that last script, you will have repeating timer all the time. Not need worry rounds anymore
Bacardi 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:29.


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