SA-MP Forums Archive
Get current gamemode name? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Get current gamemode name? (/showthread.php?tid=589752)



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:-
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


Re: Get current gamemode name? - Gammix - 22.09.2015

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...


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:-
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.


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)