Raised This Month: $ Target: $400
 0% 

Help on a simple script


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
blitzzz
Member
Join Date: Mar 2010
Old 10-10-2010 , 11:01   Help on a simple script
Reply With Quote #1

Can someone look over portion of code for me? What i was trying to do is to print some default messages to the public channel, but i'm trying to make it not print the 2nd msg (with colors)if the 1st msg (no colors) is already printed. So, upon checking the cvar, if condition is fulfilled (Cvarcondition = 1), it will print out default msg 1 and checksay is set to true. Now that default msg 1 is already printed, i do not need default msg 2 so i set if(checksay = true) { return Plugin_Stop;}. However, upon compiling, i got an error saying undefined symbol: checksay. Can anyone tell me what i've done wrong?

public OnClientAuthorized(client, const String:auth[])
{
Action1;
Action2;
}
Action1(client, args)
{
new bool:checksay = false;
if( GetConVarInt(Cvarcondition))
{
PrintToChatAll("%s default message1", client);
checksay = true;
}
}

Action2(client, args)
{
if(checksay = true)
{ return Plugin_Stop;}
else
{return Plugin_Continue;}

CPrintToChatAll("%s default message2", client);

}

Last edited by blitzzz; 10-10-2010 at 11:07.
blitzzz is offline
Lord Canistra
Senior Member
Join Date: Mar 2009
Location: Tallinn, Estonia
Old 10-10-2010 , 11:20   Re: Help on a simple script
Reply With Quote #2

Post your code inbetween tags.

First, your function calls are obscure.
>Action1;
Where is parameter list? It should look like Action1(client, my_arg_var);
If you want to use checksay variable in several functions, you should define it somewhere else, outside Action1 or any other's function body.
__________________
Lord Canistra is offline
thetwistedpanda
Good Little Panda
Join Date: Sep 2008
Old 10-10-2010 , 12:48   Re: Help on a simple script
Reply With Quote #3

Here's the proper way to code what you were trying to do. But a major "what the hell are you trying to do" comes to mind while writing it . If you could give us more information we'd help you get on the right track, mhm mhm.

PHP Code:
/*
    Note: Trying to not print the second message, if the first message has been printed.
    Useful Link: http://wiki.alliedmods.net/Category:SourceMod_Scripting
*/

//Need a handle to store the Cvar into
new Handle:g_hCvar INVALID_HANDLE;

//Need to declare our Cvar somewhere, so we do it in OnPluginStart()
public OnPluginStart()
{
    
//Create our ConVar ~ http://docs.sourcemod.net/api/index.php?fastload=show&id=475&
    
g_hCvar CreateConVar("sm_scriptname_cvaridentifier""1""If enabled, print without colors.inc, otherwise, print with it."FCVAR_NONEtrue0.0true1.0);
}

//Client has been authorized as a valid player, not sure about admin yet, but it doesn't matter
public OnClientAuthorized(client, const String:auth[])
{
    
//If Action1 Fails, do Action2
    
if(!DoAction1(client))
        
DoAction2(client);
}

//Going to return a value
bool:DoAction1(client)
{
    if(!
GetConVarInt(g_hCvar))
        return 
false;
    
    
//Print to chat. Don't use %s for an integer! http://wiki.alliedmods.net/Format_Class_Functions_(SourceMod_Scripting)
    
PrintToChatAll("\x04%N ~ \x03Default Message"client);
    return 
true;
}

//Doesn't need to return a value
void:DoAction2(client)
{
    
//Print to chat. Don't use %s for an integer! http://wiki.alliedmods.net/Format_Class_Functions_(SourceMod_Scripting)
    
CPrintToChatAll("{green}%N ~ {lightgreen}Default Message"client);

__________________
thetwistedpanda 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:08.


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