Get current gamemode name?
#1

Is possible to get the current gamemode name running in the server? I wanna show a message at the players who joins like: "You're currently playing Map Name". Thanks.
Reply
#2

According to your previos post, i think you should use SVars (SetSVarString).

Set the gamemode name using SetSVarString in your gamemodes and read the value form the main core, you mentioned using GetSVarString.
Reply
#3

Care to make me an example code? Thanks so much.
Reply
#4

Under defines:-
PHP код:
new gmName[64]; 
OnGamemodeInit:
PHP код:
gmName "gamemode name you used in SetGameModeText"
and anywhere just call the variable gmName to get the gamemode name :P
Reply
#5

Quote:
Originally Posted by karemmahmed22
Посмотреть сообщение
Under defines:-
PHP код:
new gmName[64]; 
OnGamemodeInit:
PHP код:
gmName "gamemode name you used in SetGameModeText"
and anywhere just call the variable gmName to get the gamemode name :P
You can't access local/script variables or arrays on other platforms.

OT:
Lets say you have a gamemode (say GM1.pwn). So in order to write its name, use SetSVarString in OnGameModeInit.
pawn Код:
public OnGameModeInit() {
    SetSVarString("GM_Name", "your mode name");
}
Now in your filterscript, you can simply get the name by:
pawn Код:
new ModeName[45];
GetSVarString("GM_Name", ModeName, sizeof(ModeName));
Use it in client message, textdraws...
Reply
#6

Theres no such a thing named SetSVarInt ... lol
Reply
#7

Quote:
Originally Posted by karemmahmed22
Посмотреть сообщение
Theres no such a thing named SetSVarInt ... lol
I hope you know that SVars were added in 0.3.7.
Reply
#8

error 017: undefined symbol "SetSVarString"

And im using 0.3.7...
Reply
#9

Quote:
Originally Posted by karemmahmed22
Посмотреть сообщение
Under defines:-
PHP код:
new gmName[64]; 
OnGamemodeInit:
PHP код:
gmName "gamemode name you used in SetGameModeText"
and anywhere just call the variable gmName to get the gamemode name
you should use this, since you need to do it in the gamemode itself, if you wanna do it in filterscript, maybe create a file (txt or ini) and save the gamemode name, retrive from the filterscript.
Reply
#10

@Face9000:

pawn Код:
// Server wide persistent variable system (SVars)
native SetSVarInt(varname[], int_value);
native GetSVarInt(varname[]);
native SetSVarString(varname[], string_value[]);
native GetSVarString(varname[], string_return[], len);
native SetSVarFloat(varname[], Float:float_value);
native Float:GetSVarFloat(varname[]);
native DeleteSVar(varname[]);
From my a_samp.inc (make usre you have 0.3.7 R2-1, because they were added in the latest update)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)