AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to get keyvalue for trigger_changelevel? (https://forums.alliedmods.net/showthread.php?t=312146)

MihaiGamerXD 11-18-2018 10:00

How to get keyvalue for trigger_changelevel?
 
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?

OciXCrom 11-18-2018 12:50

Re: How to get keyvalue for trigger_changelevel?
 
Read the documentation:

Quote:

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

JocAnis 11-19-2018 06:08

Re: How to get keyvalue for trigger_changelevel?
 
getting ANY built-map entity's keyvalue is only possible on their spawn, and im hoping im not right cuz its too annoying :/

klippy 11-19-2018 07:22

Re: How to get keyvalue for trigger_changelevel?
 
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.

MihaiGamerXD 11-21-2018 11:58

Re: How to get keyvalue for trigger_changelevel?
 
I want to get "map" keyvalue to know what map will change.

klippy 11-21-2018 12:20

Re: How to get keyvalue for trigger_changelevel?
 
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.

MihaiGamerXD 11-21-2018 12:56

Re: How to get keyvalue for trigger_changelevel?
 
I can't find offsets!

JocAnis 11-21-2018 17:06

Re: How to get keyvalue for trigger_changelevel?
 
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.. ?

MihaiGamerXD 11-22-2018 13:42

Re: How to get keyvalue for trigger_changelevel?
 
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?

JocAnis 12-08-2018 07:46

Re: How to get keyvalue for trigger_changelevel?
 
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 )



All times are GMT -4. The time now is 07:34.

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