Raised This Month: $ Target: $400
 0% 

Show both Name and Steam ID


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Rirre
Veteran Member
Join Date: Nov 2006
Old 01-17-2011 , 09:56   Show both Name and Steam ID
Reply With Quote #1

New to entity_get_string.
I would like to get the player steam id also and not just the name of him.
How can I get AuthID/Steam ID of him?
PHP Code:
            new Name[32];
           
entity_get_string(entEV_SZ_targetnameName31);    

            new 
AuthID[32];
            
entity_get_string(entEV_SZ_targetnameAuthID31);
        
            if(!
strcmp(Name"")) {
                
strcat(Name"Unknown"32);
            }

            if(!
strcmp(AuthID"")) {
                
strcat(AuthID"Unknown"32);
            } 
Rirre is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 01-17-2011 , 10:02   Re: Show both Name and Steam ID
Reply With Quote #2

get_user_name
get_user_authid
__________________
Impossible is Nothing
Sylwester is offline
Rirre
Veteran Member
Join Date: Nov 2006
Old 01-17-2011 , 10:04   Re: Show both Name and Steam ID
Reply With Quote #3

I've already try with get_user_authid(ent, AuthID, 32);
but it doesn't work. Just "unknown" message then.
Rirre is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-17-2011 , 10:05   Re: Show both Name and Steam ID
Reply With Quote #4

Show your code.
__________________
Arkshine is offline
Rirre
Veteran Member
Join Date: Nov 2006
Old 01-17-2011 , 10:29   Re: Show both Name and Steam ID
Reply With Quote #5

Just figured out I posted in the wrong forum section.
This thread belong to "Suggestions" forum (used to post help in "Scripting Help").
Anyway, the whole code is so long so I just post the necessary there "name" and "authid" is located.
PHP Code:
public client_PreThink(id)
{
    
//make sure player is connected
    
if (is_user_connected(id))
    {
        
//display type of block that player is aiming at
        
new entbody;
        
get_user_aiming(identbody320);
        
        if (
isBlock(ent))
        {
            new 
blockType entity_get_int(entEV_INT_body);
            new 
Name[32];
            
entity_get_string(entEV_SZ_targetnameName31);    

            new 
AuthID[32];
            
entity_get_string(entEV_SZ_targetnameAuthID31);
        
            if(!
strcmp(Name"")) {
                
strcat(Name"Unknown"32);
            }

            if(!
strcmp(AuthID"")) {
                
strcat(AuthID"Unknown"32);
            }
        
            
set_hudmessage(gHudRedgHudGreengHudBluegfTextXgfTextYgHudEffectsgfHudFxTimegfHudHoldTimegfHudFadeInTimegfHudFadeOutTimegHudChannel);
            
show_hudmessage(id"%s^n%s^n%s"gszBlockNames[blockType], NameAuthID);
        } 
PHP Code:
saveBlocks(id)
{
    
//make sure player has access to this command
    
if (get_user_flags(id) & BM_ADMIN_LEVEL)
    {
        new 
file fopen(gszNewFile"wt");
        new 
ent = -1;
        new 
blockType;
        new 
Float:vOrigin[3];
        new 
Float:vAngles[3];
        new 
Float:vStart[3];
        new 
Float:vEnd[3];
        new 
blockCount 0;
        new 
teleCount 0;
        new 
timerCount 0;
        new 
szData[612];
        new 
Float:fMax;
        new 
size;
        new 
Float:vSizeMax[3];
        new 
Name[32];
        new 
AuthID[32];

        while ((
ent find_ent_by_class(entgszBlockClassname)))
        {
            
//get block info
            
blockType entity_get_int(entEV_INT_body);
            
entity_get_vector(entEV_VEC_originvOrigin);
            
entity_get_vector(entEV_VEC_anglesvAngles);
            
entity_get_vector(entEV_VEC_maxsvSizeMax);
            
entity_get_string(entEV_SZ_targetnameName31);
            
entity_get_string(entEV_SZ_targetnameAuthID31);

            
size SMALL;
            
fMax vSizeMax[0] + vSizeMax[1] + vSizeMax[2];
            if (
fMax 64.0size NORMAL;
            if (
fMax 128.0size LARGE;
            
            
//format block info and save it to file
            
formatex(szData612"%c %f %f %f %f %f %f %d %s %s^n"gBlockSaveIds[blockType], vOrigin[0], vOrigin[1], vOrigin[2], vAngles[0], vAngles[1], vAngles[2], sizeNameAuthID);
            
fputs(fileszData);
            
            
//increment block count
            
++blockCount;
        } 
PHP Code:
loadBlocks(id)
{
    new 
bool:bAccess false;
    
    
//if this function was called on map load, ID is 0
    
if (id == 0)
    {
        
bAccess true;
    }
    
//make sure user calling this function has access
    
else if (get_user_flags(id) & BM_ADMIN_LEVEL)
    {
        
bAccess true;
    }
    
    if (
bAccess)
    {
        
//if map file exists
        
if (file_exists(gszNewFile))
        {
            
//if a player is loading then first delete all the old blocks, teleports and timers
            
if (id && id <= 32)
            {
                
deleteAllBlocks(idfalse);
                
deleteAllTeleports(idfalse);
                
deleteAllTimers(idfalse);
            }
            
            new 
szData[612];
            new 
szType[2];
            new 
sz1[16], sz2[16], sz3[16], sz4[16], sz5[16], sz6[16], sz7[16], szName[32], szAuthID[32];
            new 
Float:vVec1[3];
            new 
Float:vVec2[3];
            new 
axis;
            new 
size;
            new 
fopen(gszNewFile"rt");
            new 
blockCount 0;
            new 
teleCount 0;
            new 
timerCount 0;
            new 
bool:bTimerStart true;
            new 
Float:vTimerOrigin[3];
            new 
Float:vTimerAngles[3];
            new 
ent;
            
            
//iterate through all the lines in the file
            
while (!feof(f))
            {
                
szType "";
                
fgets(fszData612);
                
parse(szDataszType1sz116sz216sz316sz416sz516sz616sz716szName32szAuthID32);
                
                
vVec1[0] = str_to_float(sz1);
                
vVec1[1] = str_to_float(sz2);
                
vVec1[2] = str_to_float(sz3);
                
vVec2[0] = str_to_float(sz4);
                
vVec2[1] = str_to_float(sz5);
                
vVec2[2] = str_to_float(sz6);
                
size str_to_num(sz7);
                
                if (
strlen(szType) > 0)
                {
                    
//if type is not a teleport
                    
if (szType[0] != gTeleportSaveId)
                    {
                        
//set axis orientation depending on block angles
                        
if (vVec2[0] == 90.0 && vVec2[1] == 0.0 && vVec2[2] == 0.0)
                        {
                            
axis X;
                        }
                        else if (
vVec2[0] == 90.0 && vVec2[1] == 0.0 && vVec2[2] == 90.0)
                        {
                            
axis Y;
                        }
                        else
                        {
                            
axis Z;
                        }
                        
                        
//increment block counter
                        
++blockCount;
                    }
                    
                    
//create block or teleport depending on type
                    
switch (szType[0])
                    {
                        case 
'A'ent createBlock(0BM_PLATFORMvVec1axissize);
                        
//...and so on.

                        
case gTeleportSaveId:
                        {
                            
createTeleport(0TELEPORT_STARTvVec1);
                            
createTeleport(0TELEPORT_ENDvVec2);
                            
                            
//increment teleport count
                            
++teleCount;
                        }
                        
                        case 
gTimerSaveId:
                        {
                            
//is this the first timer info retrieved from file?
                            
if (bTimerStart)
                            {
                                
//store start timer info
                                
vTimerOrigin[0] = vVec1[0];
                                
vTimerOrigin[1] = vVec1[1];
                                
vTimerOrigin[2] = vVec1[2];
                                
vTimerAngles[0] = vVec2[0];
                                
vTimerAngles[1] = vVec2[1];
                                
vTimerAngles[2] = vVec2[2];
                                
                                
//the next timer to come along is the end of the timer
                                
bTimerStart false;
                            }
                            else
                            {
                                
//create the start of timer
                                
createTimer(0TIMER_STARTvTimerOriginvTimerAngles);
                                
                                
//create the end of the timer
                                
createTimer(0TIMER_ENDvVec1vVec2);
                                
                                
//if another timer comes along then it'll be the start again
                                
bTimerStart true;
                                
                                
//increment timer count
                                
++timerCount;
                            }
                        }
                        
                        default:
                        {
                            
log_amx("%sInvalid block type: %c in: %s"gszPrefixszType[0], gszFile);
                            
                            
//decrement block counter because a block was not created
                            
--blockCount;
                        }
                    }
                    if (
is_valid_ent(ent)) {
                      
// if its there
             
if(strcmp(szName"")) {
                           
entity_set_string(entEV_SZ_targetnameszName);
                        }

             if(
strcmp(szAuthID"")) {
                           
entity_set_string(entEV_SZ_targetnameszAuthID);
                        }
                    }
                }
            } 

Last edited by Rirre; 01-17-2011 at 10:32.
Rirre is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-17-2011 , 10:31   Re: Show both Name and Steam ID
Reply With Quote #6

I mean your code with get_user_authid().
__________________
Arkshine is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 01-17-2011 , 10:32   Re: Show both Name and Steam ID
Reply With Quote #7

I mean your code with get_user_authid().
__________________
Arkshine is offline
Rirre
Veteran Member
Join Date: Nov 2006
Old 01-17-2011 , 10:33   Re: Show both Name and Steam ID
Reply With Quote #8

Oh, I just commented:
entity_get_string(ent, EV_SZ_targetname, AuthID, 31);
entity_get_string(ent, EV_SZ_targetname, szAuthID, 31);
and replaced with:
get_user_authid(ent, AuthID, 32)
get_user_authid(ent, szAuthID, 32)
Rirre is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 01-17-2011 , 12:44   Re: Show both Name and Steam ID
Reply With Quote #9

A block, itself, does not have a name or SteamID. I'm assuming you need to find the owner of the block first then get their name and SteamID.
__________________
fysiks is offline
Reply



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


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