Raised This Month: $32 Target: $400
 8% 

How to get keyvalue for trigger_changelevel?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
MihaiGamerXD
Member
Join Date: Aug 2018
Old 11-18-2018 , 10:00   How to get keyvalue for trigger_changelevel?
Reply With Quote #1

Hello, I am here for a question, how to get keyvalue for trigger_changelevel?

Example:
PHP Code:
include <amxmodx>
include <
amxmisc>
include <
engine>
include <
fakemeta>
include <
hamsandwich>

public 
plugin_init() {
    
register_plugin("Change Level","1.0","MihaiGamerXD")
    
RegisterHam(Ham_Touch,"trigger_changelevel","ChangeLevel",1)
}

public 
ChangeLevel() {
    new 
mapname[32]
    
copy_keyvalue("trigger_changelevel"63"map"63mapname31)
    
server_cmd("changelevel %s",mapname)

But it doesn't work. I did something wrong?
MihaiGamerXD is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 11-18-2018 , 12:50   Re: How to get keyvalue for trigger_changelevel?
Reply With Quote #2

Read the documentation:

Quote:
Can only be used inside the pfn_keyvalue() forward.
What kind of value are you trying to get?
__________________

Last edited by OciXCrom; 11-18-2018 at 12:51.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
JocAnis
Veteran Member
Join Date: Jun 2010
Old 11-19-2018 , 06:08   Re: How to get keyvalue for trigger_changelevel?
Reply With Quote #3

getting ANY built-map entity's keyvalue is only possible on their spawn, and im hoping im not right cuz its too annoying :/
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-19-2018 , 07:22   Re: How to get keyvalue for trigger_changelevel?
Reply With Quote #4

Keyvalues are parsed and certain actions (like setting some member variables etc) are instantly taken based on these keys and values; they are not saved anywhere.
However, because values usually end up being saved in entity's member variables, there may be ways to get them (usually not in original plaintext format), but you'll have to figure that out yourself by reading HLSDK / ReGameDLL_CS.
__________________

Last edited by klippy; 11-19-2018 at 07:25.
klippy is offline
MihaiGamerXD
Member
Join Date: Aug 2018
Old 11-21-2018 , 11:58   Re: How to get keyvalue for trigger_changelevel?
Reply With Quote #5

I want to get "map" keyvalue to know what map will change.
MihaiGamerXD is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 11-21-2018 , 12:20   Re: How to get keyvalue for trigger_changelevel?
Reply With Quote #6

It's stored in CChangeLevel::m_szMapName.
If you are running 1.8.3/1.9 you can do
Code:
new mapName[32];
get_ent_data_string(entityId, "CChangeLevel", "m_szMapName", mapName, charsmax(mapName));
if it's 1.8.2, you'll have to use get_pdata_string and find offsets yourself, depending on what game you are writing the plugin for.
__________________
klippy is offline
MihaiGamerXD
Member
Join Date: Aug 2018
Old 11-21-2018 , 12:56   Re: How to get keyvalue for trigger_changelevel?
Reply With Quote #7

I can't find offsets!
MihaiGamerXD is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 11-21-2018 , 17:06   Re: How to get keyvalue for trigger_changelevel?
Reply With Quote #8

nice find klipice!
if anyone with using 1.8.2 want to get this changelevel thing for example, from here: https://forums.alliedmods.net/showpo...2&postcount=29

will he use
Code:
server_print( "changeleve is: %s", get_pdata_string( ent_id, 73 ) )
or not in that way ?
edit: ok ofc not in that way cuz multiple things have that 73 definition...can you explain a little more about this get_pdata thing, how to correctly find the right thing you need, how to use.. ?
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)

Last edited by JocAnis; 11-21-2018 at 17:08.
JocAnis is offline
MihaiGamerXD
Member
Join Date: Aug 2018
Old 11-22-2018 , 13:42   Re: How to get keyvalue for trigger_changelevel?
Reply With Quote #9

PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <engine>
#include <fakemeta>
#include <hamsandwich>

new mapname[32]

public 
plugin_init() {
    
register_plugin("Change Level""1.0""MihaiGamerXD")
    
RegisterHam(Ham_Touch,"trigger_changelevel","ChangeLevel",1)
}

public 
ChangeLevel() {
    
server_cmd("changelevel %s",mapname)
}

public 
pfn_keyvalue(entid) {
    
get_pdata_string(entid,73,mapname,31,1,0)

but it doesn't work! I did something wrong?

Last edited by MihaiGamerXD; 11-22-2018 at 13:43.
MihaiGamerXD is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 12-08-2018 , 07:46   Re: How to get keyvalue for trigger_changelevel?
Reply With Quote #10

im feeling like i have to post it, so if anyone needs this here you are:
if you want to get door's wait value (not so many times wanted on the forums, but without solution) you can with:
Code:
m_flWait = 44

new Float: srbin =  get_pdata_float( doorENT, 44  ) 
client_print( id, print_chat, "Closing the door for: %.01f", srbin )
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)

Last edited by JocAnis; 12-08-2018 at 07:47.
JocAnis is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:28.


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