AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Some help... (https://forums.alliedmods.net/showthread.php?t=318134)

mentalproblems 08-15-2019 17:09

Some help...
 
If I'm wanting to set a knife model to work only with my SteamID.

How do I do that... How do I actually make the plugin recognize my ID...

if (get_user_authid(id) == "STEAM:1:0_ID") or?... anyone to explain me how to?

Thank u.


What I mean is, how do I make this work?

PHP Code:

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

#define ADMINFLAG    ADMIN_LEVEL_G

new const myid[] = "STEAM_0:1:xxxxxx"

new const v_Knife_Admin[64] = "models/rgc_vip/v_vip_knife.mdl"
new const v_Knife_myknife[64] = "models/rgc_vip/v_alb_knife.mdl"

public plugin_init() {
    
register_plugin("Admin/VIP Knife Models""2.0""nobody")
    
register_event("CurWeapon""Event_CurWeapon""be""1=1")
}

public 
plugin_precache() {
    
precache_model(v_Knife_Admin)
    
precache_model(v_Knife_myknife)
}

public 
Event_CurWeapon(id) {
    new 
weapon read_data(2)
    
    if (
get_user_authid(idmyidcharsmax(myid)) && (weapon == CSW_KNIFE) {
        
set_pev(idpev_viewmodel2v_Knife_myknife)
    }
    else if(
get_user_flags(id) == ADMINFLAG && weapon == CSW_KNIFE) {
        
set_pev(idpev_viewmodel2v_Knife_Admin)
    }



OciXCrom 08-15-2019 17:21

Re: Some help...
 
Please use descriptive titles, it only takes 10 more seconds of your time, but makes the life of 1000 more people easier.

"get_user_authid" returns a string, so you need to store it in a buffer and compare it using the "equal" function.

mentalproblems 08-15-2019 17:25

Re: Some help...
 
What you told me right now is just too big for me to absorb, can you simply fix the code for me there if possible. Thank you.

thEsp 08-15-2019 17:28

Re: Some help...
 
Quote:

PHP Code:

get_user_authid(id) == 


This native does not return a string, it formats the given string (second argument).

Quote:

STEAM:1
Wait, are you from the future?

mentalproblems 08-15-2019 17:30

Re: Some help...
 
So if (get_user_authid(id) == STEAM:1:0_xxxxx) { ?

thEsp 08-15-2019 17:38

Re: Some help...
 
Code:
#include <amxmodx> #include <fakemeta> #include <hamsandwich> new const szOwnerSID[] = "..."; new const szKnifeModel[] = "models/{modelname}.mdl"; // CBasePlayerItem new const m_pPlayer = 41; public plugin_init() {      RegisterHam(Ham_Item_Deploy, "weapon_knife", "hamDeploy_post", 1); } public plugin_precache() {     precache_model(szKnifeModel); } public hamDeploy_post(iEnt) {     new id = get_pdata_cbase(iEnt, m_pPlayer, 4);     if(!id)         return;         new szUserSID[32];     get_user_authid(id, szUserSID, charsmax(szUserSID));     if(equal(szUserSID, szOwnerSID))         set_pev(id, pev_viewmodel2, szKnifeModel); }
Untested.
PS: Next time us a better title for your thread, instead of jabaiting the members.

OciXCrom 08-16-2019 08:39

Re: Some help...
 
Quote:

Originally Posted by mentalproblems (Post 2663417)
What you told me right now is just too big for me to absorb, can you simply fix the code for me there if possible. Thank you.

This section is for learning, not waiting for someone else do to the stuff for you. If you want someone to fix the code for you, use the requests section.


All times are GMT -4. The time now is 17:25.

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