Raised This Month: $51 Target: $400
 12% 

Problem with native from zp


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CamerDisco
AlliedModders Donor
Join Date: Aug 2015
Location: Poland
Old 07-21-2016 , 14:50   Problem with native from zp
Reply With Quote #1

Hi, I'm making it: https://forums.alliedmods.net/showthread.php?t=281884
But without zp include.
I've problem with
PHP Code:
native int ZP_GetClientViewModel(int clientIndex); 
beacuse it's writed on c++ and I don't know how to bring it to sp
PHP Code:
    CreateNative("ZP_GetClientViewModel",        APICallViewModel); 
PHP Code:
public int APICallViewModel(Handle isPluginint iNumParams)
{
    
// Get real player index from native cell 
    
CBasePlayercBasePlayer view_as<CBasePlayer>(GetNativeCell(1));

    
// Return value
    
return cBasePlayer->m_nModelIndex;

CamerDisco is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 07-21-2016 , 14:56   Re: Problem with native from zp
Reply With Quote #2

it's not written in c++
I think his just using the new syntax / method mao
__________________
8guawong is offline
Farbror Godis
AlliedModders Donor
Join Date: Feb 2016
Old 07-21-2016 , 15:01   Re: Problem with native from zp
Reply With Quote #3

Looks like SourcePawn but cBasePlayer seems to be a pointer. (what's going on?).

Last edited by Farbror Godis; 07-21-2016 at 15:03.
Farbror Godis is offline
CamerDisco
AlliedModders Donor
Join Date: Aug 2015
Location: Poland
Old 07-21-2016 , 15:48   Re: Problem with native from zp
Reply With Quote #4

I've problem with use this, I tried
PHP Code:
     CreateNative("ZP_GetClientViewModel",        APICallViewModel); 
And next to:
PHP Code:
public int APICallViewModel(Handle pluginint numParams)
{
    
int client GetNativeCell(1);
    
// Validate client here
    
GetEntProp(clientProp_Send"m_nModelIndex");

But this is native with client
PHP Code:
     SetViewModel(weaponIndexZP_GetClientViewModel(clientIndex), iViewModel); 
So I must use
PHP Code:
                        native int ZP_GetClientViewModel(int clientIndex); 
But it can't be 2x.

Last edited by CamerDisco; 07-21-2016 at 15:48.
CamerDisco is offline
CamerDisco
AlliedModders Donor
Join Date: Aug 2015
Location: Poland
Old 07-22-2016 , 08:08   Re: Problem with native from zp
Reply With Quote #5

Ok, I did it, I made this native on another plugin, but I don't see new model, I hear new sounds and new model if I droped this gun, but on my hands I see only ak47.

PHP Code:
 #include <camer> 
on camer.inc I've:
PHP Code:
native int ZP_GetClientViewModel(int clientIndex); 
And on another one plugin I've:
PHP Code:
#include <sourcemod>

public OnPluginStart()
{
    
CreateNative("ZP_GetClientViewModel",        APICallViewModel);  
}

public 
int APICallViewModel(Handle pluginint numParams)
{
    
int client GetNativeCell(1);
    
// Validate client here
    
GetEntProp(clientProp_Send"m_nModelIndex");

And on my plugin with new model I have function from zp
PHP Code:
    SetViewModel(weaponIndexZP_GetClientViewModel(clientIndex), iViewModel); 

PHP Code:
stock void SetViewModel(int weaponIndexint viewIndexint model)
{
    
// Delete model index
    
SetEntProp(weaponIndexProp_Send"m_nModelIndex"0);
    
    
// Set view model for weapon
    
SetEntProp(viewIndexProp_Send"m_nModelIndex"model);

CamerDisco is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 07-22-2016 , 08:39   Re: Problem with native from zp
Reply With Quote #6

why don't you just use https://forums.alliedmods.net/showthread.php?t=276697
__________________
8guawong is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 07-22-2016 , 11:18   Re: Problem with native from zp
Reply With Quote #7

In snippet I posted, I forgot to put "return " before "GetEntProp"
__________________
WildCard65 is offline
CamerDisco
AlliedModders Donor
Join Date: Aug 2015
Location: Poland
Old 07-22-2016 , 13:01   Re: Problem with native from zp
Reply With Quote #8

PHP Code:
public int APICallViewModel(Handle pluginint numParams)
{
    
int client GetNativeCell(1);
    return 
Plugin_Handled;
    
GetEntProp(clientProp_Send"m_nModelIndex");

?
I think there should be another return yea?

Last edited by CamerDisco; 07-22-2016 at 13:15.
CamerDisco is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 07-22-2016 , 13:39   Re: Problem with native from zp
Reply With Quote #9

Perfected native backend:

PHP Code:
public int APICallViewModel(Handle pluginint numParams)
{
    
int client GetNativeCell(1);
    
// Validate client here
    
return GetEntProp(clientProp_Send"m_nModelIndex");

__________________
WildCard65 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 05:19.


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