Get current gamemode name? -
Face9000 - 22.09.2015
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.
Re: Get current gamemode name? -
Gammix - 22.09.2015
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.
Re: Get current gamemode name? -
Face9000 - 22.09.2015
Care to make me an example code? Thanks so much.
Re: Get current gamemode name? -
karemmahmed22 - 22.09.2015
Under defines:-
OnGamemodeInit:
PHP код:
gmName = "gamemode name you used in SetGameModeText";
and anywhere just call the variable gmName to get the gamemode name :P
Re: Get current gamemode name? -
Gammix - 22.09.2015
Quote:
Originally Posted by karemmahmed22
Under defines:-
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...
Re: Get current gamemode name? -
karemmahmed22 - 22.09.2015
Theres no such a thing named SetSVarInt ... lol
Re: Get current gamemode name? -
Gammix - 22.09.2015
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.
Re: Get current gamemode name? -
Face9000 - 22.09.2015
error 017: undefined symbol "SetSVarString"
And im using 0.3.7...
Re: Get current gamemode name? -
karemmahmed22 - 22.09.2015
Quote:
Originally Posted by karemmahmed22
Under defines:-
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.
Re: Get current gamemode name? -
Gammix - 22.09.2015
@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)