Raised This Month: $114 Target: $400
 28% 

Need help for complied errors


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
reid123455
Junior Member
Join Date: May 2015
Old 03-03-2019 , 04:16   Need help for complied errors
Reply With Quote #1

Hello everyone!
Sorry for my bad English first.
And I've never written any plugin or program before.
I can only use C to print a Xmas tree in console.

But I want to give myself a big challenge, so I try to write a simple plugin by myself.

Here is my idea of this plugin:
I just want to restrict everyone's movement until warmup is end in CS:GO.

Here is my source code:
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);
    new 
MaxClients GetConVarInt(FindConVar("maxplayers"));
    new 
GetWarmUpTime GetConVarInt(FindConVar("mp_warmuptime"));
    
    if(
team == || team == 3)
    {
        for (new 
1<= MaxClientsi++)
        {
            if (
IsClientInGame(i) && IsPlayerAlive(i))
            {
                
SetEntityMoveType(iMOVETYPE_NONE); 
            }
        }
        
        
PrintToChatAll(client"Please wait for other players connect.");
    }
    
    while(
GetWarmUpTime != 0//keep checking if wamrup time == 0
    
{    
        new 
GetWarmUpTime CreateTimer(GetWarmUpTime); //Sorry. I really don't understand CreateTimer().
    
}
    
    if(
GetWarmUpTime == 0)
    {
        for(new 
1<= MaxClientsi++)
        {
            if (
IsClientInGame(i) && IsPlayerAlive(i))
            {
                
SetEntityMoveType(iMOVETYPE_WALK); 
            }
        }
        
        
PrintToChatAll(client"Game is going to start!");
    }
    

Due to my bad logic, this is may be a terrible and horrible code
And I got these errors:
Code:
//// WarmupWaiting.sp
// D:\Server\csgo server\csgo\addons\sourcemod\scripting\WarmupWaiting.sp(27) : warning 219: local variable "MaxClients" shadows a variable at a preceding level
// D:\Server\csgo server\csgo\addons\sourcemod\scripting\WarmupWaiting.sp(40) : error 035: argument type mismatch (argument 1)
// D:\Server\csgo server\csgo\addons\sourcemod\scripting\WarmupWaiting.sp(45) : warning 219: local variable "GetWarmUpTime" shadows a variable at a preceding level
// D:\Server\csgo server\csgo\addons\sourcemod\scripting\WarmupWaiting.sp(45) : warning 213: tag mismatch
// D:\Server\csgo server\csgo\addons\sourcemod\scripting\WarmupWaiting.sp(45) : error 092: number of arguments does not match definition
// D:\Server\csgo server\csgo\addons\sourcemod\scripting\WarmupWaiting.sp(45) : warning 213: tag mismatch
// D:\Server\csgo server\csgo\addons\sourcemod\scripting\WarmupWaiting.sp(58) : error 035: argument type mismatch (argument 1)
//
// 3 Errors.
Can anyone help me to fix these errors? Thank you!
reid123455 is offline
Nexd
BANNED
Join Date: Dec 2013
Location: Hungary
Old 03-03-2019 , 05:55   Re: Need help for complied errors
Reply With Quote #2

Code:
error 035: argument type mismatch (argument 1)
this is because you want to print something for every client, so you should do it in this way:
PHP Code:
PrintToChatAll("Please wait for other players connect."); 
Nexd is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 03-03-2019 , 06:09   Re: Need help for complied errors
Reply With Quote #3

PHP Code:
new MaxClients GetConVarInt(FindConVar("maxplayers")); 
Remove this line, MaxClients is a global variable managed by SM.

I suggesting looking at the timer documentation: https://wiki.alliedmods.net/Timers_(...Mod_Scripting)
__________________
asherkin is offline
XiLuo
Junior Member
Join Date: Mar 2018
Old 03-03-2019 , 06:42   Re: Need help for complied errors
Reply With Quote #4

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.
XiLuo is offline
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
impossible_cc
Senior Member
Join Date: Sep 2018
Location: Ukraine
Old 03-03-2019 , 12:20   Re: Need help for complied errors
Reply With Quote #6

I did not test it, but it should work.

I changed your logic actually, I'm sorry if it is a bit difficult for you.
Also I prefer new syntax, it is more familiar to me, because it is closer to 'C' syntax
Feel free to ask questions


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 
void OnMapStart() 

    
//new GetWarmUpTime = GetConVarInt(FindConVar("mp_warmuptime")); 
    //CreateTimer(GetWarmUpTime*1.0,WarmUpOver); //let GetWarmUpTime be float and set WarmUpOver callback 
    
    
float GetWarmUpTime = (FindConVar("mp_warmuptime")).FloatValue
    if(
GetWarmUpTime 0.0)
    {
        
HookEvent("player_spawn"OnPlayerSpawnEventHookMode_Post);
        
        
CreateTimer(GetWarmUpTime,WarmUpOver);
    }


public 
void OnPlayerSpawn(Event event, const char[] namebool dontBroadcast
{
    
int client GetClientOfUserId(event.GetInt("userid"));
    
    if(
IsClientInGame(client) && IsPlayerAlive(client))
    {
        
SetEntityMoveType(clientMOVETYPE_NONE);  
    }
    
    
PrintCenterText(client"Please wait for other players connect"); 
    
PrintToChat(client"Please wait for other players connect."); 


public 
Action WarmUpOver(Handle timer
{
    
UnhookEvent("player_spawn"OnPlayerSpawnEventHookMode_Post);        //We don't need it anymore, so unhook.
    
    
for(int i 1<= MaxClientsi++) 
    { 
        if (
IsClientInGame(i) && IsPlayerAlive(i)) 
        { 
            
SetEntityMoveType(iMOVETYPE_WALK);  
        } 
    }
    
    
PrintCenterTextAll("Game is going to start!"); 
    
PrintToChatAll("Game is going to start!"); 


Last edited by impossible_cc; 03-03-2019 at 12:23.
impossible_cc is offline
Cruze
Veteran Member
Join Date: May 2017
Old 03-03-2019 , 12:23   Re: Need help for complied errors
Reply With Quote #7

Compile it here!
Untested
Attached Files
File Type: sp Get Plugin or Get Source (Warmup_Freeze.sp - 33 views - 926 Bytes)
__________________
Taking paid private requests! Add me on steam/discord!
AlliedModders Releases | Github | Private Plugins | PayPal | Steam | My Discord Server

Last edited by Cruze; 03-03-2019 at 12:28.
Cruze is offline
Nexd
BANNED
Join Date: Dec 2013
Location: Hungary
Old 03-03-2019 , 15:08   Re: Need help for complied errors
Reply With Quote #8

PHP Code:
if (GameRules_GetProp("m_bWarmupPeriod") == 1
edit: sry, i haven't downloaded cruze's code before

Last edited by Nexd; 03-03-2019 at 15:20.
Nexd is offline
reid123455
Junior Member
Join Date: May 2015
Old 03-04-2019 , 06:50   Re: Need help for complied errors
Reply With Quote #9

Quote:
Originally Posted by Cruze View Post
Wow, thanks a lot.
I really appreciate it, it's working perfectly.
But I still don't understand why I get errors if using my compiler.

impossible_cc's version can be compiled in this website, but plugin still failed to work
without any errors.

But thank you guys. I've learned a lot from these threads.

Last edited by reid123455; 03-04-2019 at 06:51.
reid123455 is offline
Cruze
Veteran Member
Join Date: May 2017
Old 03-04-2019 , 06:52   Re: Need help for complied errors
Reply With Quote #10

Quote:
Originally Posted by reid123455 View Post
Wow, thanks a lot.
I really appreciate it, it's working perfectly.
But I still don't understand why I get errors if using my compiler.

impossible_cc's version can be compiled in this website, but plugin still failed to work
without any errors.

But thank you guys. I've learned a lot from these threads.
Use SM 1.9 latest build to compile
__________________
Taking paid private requests! Add me on steam/discord!
AlliedModders Releases | Github | Private Plugins | PayPal | Steam | My Discord Server
Cruze is offline
Reply


Thread Tools
Display Modes

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 23:20.


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