View Single Post
reid123455
Junior Member
Join Date: May 2015
Old 03-03-2019 , 09:16   Re: Need help for complied errors
Reply With Quote #5

Quote:
Originally Posted by XiLuo View Post
PHP Code:
#include <sourcemod> 
#include <sdktools> 


public Plugin:myinfo =  

    
name "Warmup Waiting"
    
author "Reid"
    
description "Simple plugin for waiting other player's connecting by restricting movement"
    
version "0.01"
    
url "" 
}; 

public 
OnPluginStart() 

    
HookEvent("warmup_wating"OnWarmUp); 



public 
OnWarmUp(Handle:event, const String:name[], bool:dontBroadcast
    { 
    new 
userid GetEventInt(event"userid"); // Get player #userid from event 
    
new client GetClientOfUserId(userid); // Get client index by #userid 

    
new team GetClientTeam(client); 

    
//MaxClient may needn't to get , this value has define by sm and is 64
    //new MaxClients = GetConVarInt(FindConVar("maxplayers")); 

    //Try not to repeat the definition
    
new getWarmUpTime GetConVarInt(FindConVar("mp_warmuptime")); //new GetWarmUpTime = GetConVarInt(FindConVar("mp_warmuptime")); 
     
    
if(team == || team == 3
    { 
        for (new 
1<= MaxClientsi++) 
        { 
            if (
IsClientInGame(i) && IsPlayerAlive(i)) 
            { 
                
SetEntityMoveType(iMOVETYPE_NONE);  
            } 
        } 
        
        
//stock PrintToChatAll(const String:format[], any:...)
        
PrintToChatAll("Please wait for other players connect."); //PrintToChatAll(client, "Please wait for other players connect."); 
    
}
     
    
//don‘t use 'while' simplly , may cause server crash,use timer
    /*while(GetWarmUpTime != 0) //keep checking if wamrup time == 0 
    {     
        new GetWarmUpTime = CreateTimer(GetWarmUpTime); //Sorry. I really don't understand CreateTimer(). 
    } */

    //create a timer that several seconds later will carry out the callback, parameter 1 is the second , callback method for 2 , Refer to official documentation for other details
    
CreateTimer(getWarmUpTime*1.0,WarmupTimeOver);
     
    
/*if(GetWarmUpTime == 0) 
    { 
        for(new i = 1; i <= MaxClients; i++) 
        { 
            if (IsClientInGame(i) && IsPlayerAlive(i)) 
            { 
                SetEntityMoveType(i, MOVETYPE_WALK);  
            } 
        } 
         
        PrintToChatAll(client, "Game is going to start!"); 
    }  */
}

//the callback method for CreateTimer
public Action:WarmupTimeOver(Handle:timer)
{
    for(new 
1<= MaxClientsi++) 
    { 
        if (
IsClientInGame(i) && IsPlayerAlive(i)) 
        { 
            
SetEntityMoveType(iMOVETYPE_WALK);  
        } 
    } 

    
PrintToChatAll("Game is going to start!"); 

Hei , though I fix some code , I'm not sure it can work well.
I just help fix code that some methods on using , I never wrote plugin for csgo ,just for l4d2 and with my now knowledge.
so hope my fix can work or give you little help.
Sorry for my poor English.

Thanks for all replys, and thanks for XiLuo's rewrote version as well.
It compiled successfully, but plugin failed to work
I found errors from log file
Code:
L 03/03/2019 - 20:16:54: [SM] Exception reported: Game event "warmup_waiting" does not exist
L 03/03/2019 - 20:16:54: [SM] Blaming: WarmupWaiting.smx
L 03/03/2019 - 20:16:54: [SM] Call stack trace:
L 03/03/2019 - 20:16:54: [SM]   [0] HookEvent
L 03/03/2019 - 20:16:54: [SM]   [1] Line 16, WarmupWaiting.sp::OnPluginStart
L 03/03/2019 - 20:16:54: [SM] Unable to load plugin "WarmupWaiting.smx": Error detected in plugin startup (see error logs)
L 03/03/2019 - 20:17:17: [SM] Exception reported: Script execution timed out
I thought maybe because I just misunderstood how to use HookEvent
So I decided to rewrite again.

PHP Code:
#include <sourcemod>
#include <sdktools>


public Plugin:myinfo 
{
    
name "Warmup Waiting",
    
author "Reid",
    
description "Simple plugin for waiting other player's connecting by restricting movement",
    
version "0.0.1",
    
url ""
};

public 
OnClientPutInServer(client)
{
    
//new team = GetClientTeam(client);
    
new GetWarmUpTime GetConVarInt(FindConVar("mp_warmuptime"));
    
CreateTimer(GetWarmUpTime*1.0,WarmUpOver); //let GetWarmUpTime be float and set WarmUpOver callback
    
    
for (new 1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && IsPlayerAlive(i))
        {
            
SetEntityMoveType(iMOVETYPE_NONE); 
        }
    } 
    
    
PrintToChat(client"Please wait for other players connect.");
}

public 
Action:WarmUpOver(Handle:timerany:client)
{
    for(new 
1<= MaxClientsi++)
    {
        if (
IsClientInGame(i) && IsPlayerAlive(i))
        {
            
SetEntityMoveType(iMOVETYPE_WALK); 
        }
    }
    
PrintToChat(client"Game is going to start!");

This version complied successfully and didn't get any errors.
But Players still can move or go around when warmup.
I don't know why, guess I misunderstand SetEntityMoveType() function again?
By the way, I found this function from here
https://forums.alliedmods.net/showthread.php?t=273053
reid123455 is offline