AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   I need to get this right in my head.... (https://forums.alliedmods.net/showthread.php?t=206794)

WeeZick 01-26-2013 05:32

I need to get this right in my head....
 
what's the difference between a global variable and a variable in a function?
and what's an enum?
Dont blame me im not good at coding:/

Torge 01-26-2013 05:34

Re: I need to get this right in my head....
 
Global variable can be used everywhere.

Normal variable in a function can be just used in its function.

WeeZick 01-26-2013 05:50

Re: I need to get this right in my head....
 
yeah but what is an enum?

michal123 01-26-2013 05:56

Re: I need to get this right in my head....
 
Enum: http://en.wikipedia.org/wiki/Enumerated_type
Local variable: http://en.wikipedia.org/wiki/Local_variable
Global variable: http://en.wikipedia.org/wiki/Global_variable

If you want, I can show you example code.

WeeZick 01-26-2013 06:01

Re: I need to get this right in my head....
 
Yeah that whould be verry nice if you showed me a example

WeeZick 01-26-2013 06:05

Re: I need to get this right in my head....
 
But i have understanded what an variable is i think. It is when in the beggining we press { and when i want to end the function i use }?

Sylwester 01-26-2013 06:12

Re: I need to get this right in my head....
 
Pawn Picture Tutorial
Programming for starters

EpicMonkey 01-26-2013 06:16

I need to get this right in my head....
 
Dont forget to read the enum tutorial by exolent , take a look at the tut section

michal123 01-26-2013 06:19

Re: I need to get this right in my head....
 
Code:

/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "speedkill"

//Global variable
new g_GlobalValue = 50;

public plugin_init() {
        register_plugin(PLUGIN, VERSION, AUTHOR);
        register_clcmd("say /test", "ExampleTest");
}
public ExampleTest(id){
        if(is_user_alive(id)){
                //Local variable
                new g_LocalValue = 25;
               
                client_print(id, 3, "%d | %d", g_GlobalValue, g_LocalValue);
        }
        /*       
        Error, variable "g_LocalValue" not exist "Error: Undefined symbol "g_LocalValue" on line 25"
       
        client_print(id, 3, "%d | %d", g_GlobalValue, g_LocalValue);
        */
}

Global variable can be used everywhere - like Torge wrote.
Local variable can be used only in function or block, where this variable is declared.

About enum -> https://forums.alliedmods.net/showthread.php?t=140103

WeeZick 01-26-2013 06:22

Re: I need to get this right in my head....
 
The thing i wanna do is to set a steamid on my blockmaker so only that steamid can use the blockmaker, and i found this to try:
{
new SteamID[32];
get_user_authid(id, SteamID, 31);

if(equal(SteamID, STEAMID_A) || equal(SteamID, STEAMID_LAN) || g_gived_access[id])
{
if(PCM_banned[id])
{
PCM_Print(id, "You'r SteamID didnt get a match!");
PCM_Print(id, "You'r SteamID is banned from PCM.");
set_task(2.0, "Task_ShowInfo", id);
}
else
{
ShowMainMenu(id);
}
}
else
{
PCM_Print(id, "You'r SteamID didnt get a match!");
PCM_Print(id, "You'r SteamID is either banned from PCM or you arent eligble to use PCM.");
set_task(2.0, "Task_ShowInfo", id);
}
return PLUGIN_HANDLED;
}
and then my buddy said that i should make an enum and a variable that builds up those steamids
and i didnt know what a enum or variable were so now im asking.
IF ANY COULD HELP ME SET THE STEAM ID I WHOULD BE VERRY HAPPY:)


All times are GMT -4. The time now is 20:39.

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