AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Changing Maps Command (https://forums.alliedmods.net/showthread.php?t=10973)

joecaprini 03-06-2005 10:44

Changing Maps Command
 
I am writing a plugin where if you say "cm dd2" it will change your map to de_dust2, cm ca is cs_assualt, etc. But what I need is for someone to please tell me how to check a file for the name entered ex. dd2, and check the file for the map it is. Heres an example of the file:

dd2 "de_dust2"
dd2cz "de_dust2_cz"
citalycz "cs_italy_cz"

It will look for the initials you typed and then change the map to the one in the quotes. Can anyone help?

XxAvalanchexX 03-06-2005 13:23

Code:
// somehow grab what they typed in // we'll assume that the variable "foobar" // contains the abbreviated name of the map // the file to read from new file[64]; file = "addons/amxmodx/data/yourfilehere.ini"; // if file does not exist, give up now if(!file_exists(file)) {    return PLUGIN_HANDLED; } // data for reading new line, text[64], txtlen; // go through lines in the file while((line = read_file(file,line,text,63,txtlen)) != 0) {    // abbreviation for this map and the full name    new abbrev[32], mapname[32];    // split the data into the variables    parse(text,abbrev,31,mapname,31);    // get rid of quotes    remove_quotes(mapname);    // if we found a match    if(equali(abbrev,foobar)) {       server_cmd("changelevel %s",mapname); // change the map    }    break; // stop looping } return PLUGIN_HANDLED;

joecaprini 03-06-2005 17:07

wow :shock: thats a lot more compicated than I thought. I'll see if I can figure it out. Thx :mrgreen:


All times are GMT -4. The time now is 14:13.

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