AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need help with (get/set)_pdata_string (https://forums.alliedmods.net/showthread.php?t=163990)

KORD_12.7 08-06-2011 01:22

Need help with (get/set)_pdata_string
 
I want to get/set value from
PHP Code:

char m_szTeamName[TEAM_NAME_LENGTH]; // offset is 383 

I'm tried to use (get/set)_pdata_string, but it's not work =(

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fakemeta>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "KORD_12.7"

public plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("say get""get")
    
register_clcmd("say set""set")
}

public 
get(id)
{
    new 
m_szTeamName[16]
    
get_pdata_string(id383m_szTeamNamecharsmax(m_szTeamName), .linux 5)
    
    
client_print(idprint_chat"m_szTeamName is ^"%s^""m_szTeamName)
}

public 
set(id)
{
    
set_pdata_string(id383"zombie", .linux 5)


Any idea?

PS
Running hldm steam server

KORD_12.7 08-07-2011 07:14

Re: Need help with (get/set)_pdata_string
 
Problem solved, please close

Arkshine 08-07-2011 07:33

Re: Need help with (get/set)_pdata_string
 
And the solution was ?

abdul-rehman 08-07-2011 07:33

Re: Need help with (get/set)_pdata_string
 
Can u post here, how did u solved the issue.

avril-lavigne 08-07-2011 08:09

Re: Need help with (get/set)_pdata_string
 
answer is here http://amx-x.ru/viewtopic.php?f=8&t=4418

( he didnt post the answer yet there )

KORD_12.7 01-08-2012 21:30

Re: Need help with (get/set)_pdata_string
 
And the solution was

PHP Code:

#define MAX_TEAMNAME_LENGTH    16

const m_szTeamName 383
const XTRA_OFS_PLAYER 5

new szTeamName[MAX_TEAMNAME_LENGTH]

get_pdata_string(iPlayerm_szTeamName 4szTeamNameMAX_TEAMNAME_LENGTH0XTRA_OFS_PLAYER)
set_pdata_string(iPlayerm_szTeamName 4szTeamName, -1XTRA_OFS_PLAYER


ConnorMcLeod 01-09-2012 00:56

Re: Need help with (get/set)_pdata_string
 
You solved my problem with
Code:

224
{
        (1<<0) m_bChangeNameAtRespawn
        ( 1<<1) m_szNewName[]
}

Real offset are in reality 896 and 897 but i didn't think we could directly pass them, could you explain it please, i don't understand well russian :mrgreen:

Test plugin :
PHP Code:

#include <amxmodx>
#include <fakemeta>

#define VERSION "0.0.1"
#define PLUGIN ""

const XO_PLAYER 5
const m_bChangeNameAtRespawn 224
const m_szNewName 224*1

public plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")
    
register_clcmd("drop""drop")
}

public 
drop(id)
{
    if( 
get_pdata_int(idm_bChangeNameAtRespawnXO_PLAYER) & (1<<0) )
    {
        new 
szNewName[32]
        
get_pdata_string(idm_szNewNameszNewNamecharsmax(szNewName), 0XO_PLAYER)
        
client_print(idprint_chat"New Name gonna be : %s"szNewName)
    }



Edit : Haven't tested on linux but i believe you have to do *4 with extra offset as well

KORD_12.7 01-09-2012 02:30

Re: Need help with (get/set)_pdata_string
 
I will try, but my english is too bad :(.

Floats and integers have 4 bytes and when we access them throw (get/set)_pdata_(int/float) we have offset step with 4 bytes. Char have 1 byte, so we need to multiply offset to 4.

Quote:

Edit : Haven't tested on linux but i believe you have to do *4 with extra offset as well
Yep, i was think about this, but dont have ability to test on linux.


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

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