Raised This Month: $ Target: $400
 0% 

Couple of questions pertaining to small


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ronkkrop
Member
Join Date: May 2004
Old 05-05-2004 , 19:51   Couple of questions pertaining to small
Reply With Quote #1

I have a couple of questions pertaining to small, or at least the implementation of small for amx x.

1. looping? for///while, and how?
2. if statement, how?
3. is it possible to write a config file?
4. is it possible to get a steamid?
__________________
"I refuse to join any club that would have me as a member."
--Groucho Marx
Ronkkrop is offline
Send a message via ICQ to Ronkkrop Send a message via AIM to Ronkkrop Send a message via MSN to Ronkkrop Send a message via Yahoo to Ronkkrop
AssKicR
Veteran Member
Join Date: Mar 2004
Location: Norway-Europe(GTM+1)
Old 05-05-2004 , 20:00  
Reply With Quote #2

1
Code:
for ( new aa=1; aa<=32; aa++ ) {    server_print("aa == %i",aa) }

Code:
new aa=1 new bb=100 while (aa < bb) {    bb += 1    server_print("aa == %i / bb == %i",aa,bb) }

2
Code:
if (aa == bb) {    server_print("aa == bb") } else if (aa > bb) {    server_print("aa > bb") } else if (aa < bb) {    server_print("aa < bb") } else {    server_print("aa != bb") }

to avoid using many IF/ELSE switches u can use a SWITCH/CASE
Code:
new aa = random_num(1,5) switch (aa) {    case 1:server_print("aa = 1")    case 2:server_print("aa = 2")    case 3:    {       server_print("aa = 3")       server_print("OMG MAGIC NUMBER 3!!!")    }    case 4:server_print("aa = 4")    case 5:server_print("aa = 5") }

3.
Code:
stock LoadConfig() {     if(file_exists("addons/amxx/FileToLoad.ini") == 1) {         new line, stxtsize         new data[192]         while((line=read_file("addons/amxx/FileToLoad.ini",line,data,191,stxtsize))!=0)         {             if ( data[0] == ';' ) continue             if (equal("SomeValue",data)) {                 //DO STUFF!!!!             }         }     }else{         server_cmd("echo [AMXX] 404 Error!!! File Not Found!!!")         log_amx("[AMXX] 404 Error!!! File Not Found!!!")     } }

4
Code:
new SteamId[33] get_user_authid(id,SteamId,32) server_print("%i has Steamid %s",id,SteamId)
__________________
My Plugins

Got ??
AssKicR is offline
Nick
Senior Member
Join Date: Apr 2004
Location: Canada, Alberta, Cal
Old 05-05-2004 , 20:01  
Reply With Quote #3

Join any server and type status in console You'll see your steam id
__________________
Nick is offline
Send a message via MSN to Nick
AssKicR
Veteran Member
Join Date: Mar 2004
Location: Norway-Europe(GTM+1)
Old 05-05-2004 , 20:02  
Reply With Quote #4

Quote:
Originally Posted by Nick
Join any server and type status in console You'll see your steam id
this is coding questionsidiot!!!
__________________
My Plugins

Got ??
AssKicR is offline
Ronkkrop
Member
Join Date: May 2004
Old 05-05-2004 , 20:05  
Reply With Quote #5

Thanks for tellin me.

anybody wanna clear up file io, that would be great, mmmmk?

edit: oh, and you have a code issue with your while loop. That beast would go forever should be aa+=1
__________________
"I refuse to join any club that would have me as a member."
--Groucho Marx
Ronkkrop is offline
Send a message via ICQ to Ronkkrop Send a message via AIM to Ronkkrop Send a message via MSN to Ronkkrop Send a message via Yahoo to Ronkkrop
AssKicR
Veteran Member
Join Date: Mar 2004
Location: Norway-Europe(GTM+1)
Old 05-05-2004 , 20:08  
Reply With Quote #6

Moooooved Up
AssKicR is offline
FlyingMongoose
Veteran Member
Join Date: Mar 2004
Old 05-05-2004 , 20:08  
Reply With Quote #7

cases are possible as well, if you don't want to do multiple if statements
__________________
Please do NOT PM for support.

Only ask for support in plugin threads.

TunedChaos.com - Precision Tuned Game Servers
FlyingMongoose is offline
AssKicR
Veteran Member
Join Date: Mar 2004
Location: Norway-Europe(GTM+1)
Old 05-05-2004 , 20:10  
Reply With Quote #8

Moooved Up
AssKicR is offline
Ronkkrop
Member
Join Date: May 2004
Old 05-05-2004 , 20:11  
Reply With Quote #9

AssKicR, you are teh shi....

thanks man, you rock
__________________
"I refuse to join any club that would have me as a member."
--Groucho Marx
Ronkkrop is offline
Send a message via ICQ to Ronkkrop Send a message via AIM to Ronkkrop Send a message via MSN to Ronkkrop Send a message via Yahoo to Ronkkrop
FlyingMongoose
Veteran Member
Join Date: Mar 2004
Old 05-05-2004 , 20:14  
Reply With Quote #10

I was just about to edit my post for that, though you forgot to include an example of a multiple line case statement

Code:
new aa = random_num(1,5) switch (aa) {    case 1: {               server_print("aa = 1")               server_print("aa = 1[2]")            }    case 2:server_print("aa = 2")    case 3:server_print("aa = 3")    case 4:server_print("aa = 4")    case 5:server_print("aa = 5") }
__________________
Please do NOT PM for support.

Only ask for support in plugin threads.

TunedChaos.com - Precision Tuned Game Servers
FlyingMongoose 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 22:31.


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