new const

Šiame forume rašomi vartotojų klausimai/problemos su kuriomis jie susidūrė kuriant pluginus.
Post Reply
addinol
Jau po truputį tampa savu
Posts: 144
Joined: 2010 Sep 05 15:20
Skype: kasparas94

new const

Post by addinol »

Sveiki, taigi padaryti su const 1 dalyką, sakykim turiu

Code: Select all

new const g_country_name[][] ={    "Finland",    "Sweden",    "Estonia"};

Code: Select all

 new const g_country_text[sizeof g_country_name][] ={    "FI05",    "SE05",    "EE05"};
Viename metode, gaunu iš kur žaidėjas yra su geoip_country (įsaugoju į iCountry[33]), sakykim gaunu ir gaunu Estonia, dabar aš jam noriu parodyti tokį tekstą:

You are from Estonia, your text is EE05... Kaip tai padaryti ?

Bandziau
"You are from %s, your text is %s", iCountry[id], g_country_text[iCountry] )
meta error... Array must be indexed (variable "iCountry")

Bet neveikia :(

newb
Pluginų patvirtintojas
Posts: 1047
Joined: 2010 Sep 23 21:43
Location: Wonderland
Contact:

Re: new const

Post by newb »

Ka pas tave id rodo ?..

User avatar
aaarnas
Vyr. diskusijų administratorius
Posts: 3891
Joined: 2010 Aug 31 13:21
Skype: fiarno
Contact:

Re: new const

Post by aaarnas »

Taip supratau norėjai su globaliu kintamuoju, kur laikoma žaidėjo šalis:

Code: Select all

new const g_country_name[][] ={    "Finland",    "Sweden",    "Estonia"}; new const g_country_text[][] ={    "FI05",    "SE05",    "EE05"}; new p_country[33] public funckcija(id) {        new country[45], ip[30]    get_user_ip(id, ip, charsmax(ip), 1)    geoip_country(ip, country, charsmax(country))        for(new i=0; i<sizeof(g_country_name); i++) {                if(equali(country, g_country_name[i])) {                        p_country[id] = i            break;        }    }        client_print(id, print_chat, "You are from %s, your text is %s", g_country_name[p_country[id]], g_country_text[p_country[id]])}
Palikau CS pasaulį ;/ . Nebepasiekiamas.

addinol
Jau po truputį tampa savu
Posts: 144
Joined: 2010 Sep 05 15:20
Skype: kasparas94

Re: new const

Post by addinol »

Nu aš noriu padaryti, jog 1 eilutė iš names atitiktų text... Ta prasme jei žaidėjo country Estonia tada textas EE05, ir kaip tai padaryti

Nelabai supratau tą p_country[id] = i, ir ar būtina naudoti ta for()

User avatar
aaarnas
Vyr. diskusijų administratorius
Posts: 3891
Joined: 2010 Aug 31 13:21
Skype: fiarno
Contact:

Re: new const

Post by aaarnas »

For naudojam, nes reikia rasti, kuris elementas yra šalies pavadinimas g_country_name masyve, o kadangi masyvo g_country_text numeriai taip pat atitinka, tai jei žinome elemento numerį g_country_name, tai įrašę jį į g_country_text mums duos reikiamą tekstą.
Palikau CS pasaulį ;/ . Nebepasiekiamas.

addinol
Jau po truputį tampa savu
Posts: 144
Joined: 2010 Sep 05 15:20
Skype: kasparas94

Re: new const

Post by addinol »

ok, dėkui, lyg ir veikia :)

Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests