Raised This Month: $ Target: $400
 0% 

Plugin Help


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wugagagaga
Member
Join Date: Aug 2014
Old 11-04-2023 , 08:33   Plugin Help
Reply With Quote #1

how to run on CSS sources
CSS source not supported Protobuf

i rookie thank you for your help

PHP Code:
[PHP]#include <sourcemod>
#include <sdktools>
#include <zombiereloaded>
#include <zp_level>
#include <colors>

new UserMsg:g_FadeUserMsgId;
new 
Float:g_DrugAngles[20] = {0.05.010.015.020.025.020.015.010.05.00.0, -5.0, -10.0, -15.0, -20.0, -25.0, -20.0, -15.0, -10.0, -5.0};

new 
Handle:g_drug_timer[MAXPLAYERS+1] = INVALID_HANDLE;
new 
Handle:g_speed_timer[MAXPLAYERS+1] = INVALID_HANDLE;
new 
Handle:g_Cvar_FoodEnabled INVALID_HANDLE;

new 
String:foodname[][] = 
{
    
/* +HP~ */
    
"30HP",
    
"25HP",
    
}

int foodamount[] =
{
    
30,
    
25,
    
}

// 0 - None, 1 - Speed, 2 - Drug
int foodskills[] =
{
    
0,
    
0,
    
0,
    
0,
    
1// 5
    
0,
    
0,
    
0,
    
0,
    
0// 10
    
2,
    
0,
    
0,
    
0
}

public 
Plugin:myinfo 
{
    
name "[ZM] Item:[Food]",
    
author "Zombie Paradise",
    
description "",
    
version "1.3",
    
url ""
}

public 
OnPluginStart()
{
    
RegConsoleCmd("sm_food"Clcmd_Food);
    
LoadTranslations("zp_food");
    
    
g_FadeUserMsgId GetUserMessageId("Fade");
    
    
HookEvent("round_end"Event_RoundEndEventHookMode_PostNoCopy);
    
HookEvent("player_spawn"Event_Player_Spawn);
    
HookEvent("player_death"Event_Player_Death);    
    
    
g_Cvar_FoodEnabled CreateConVar("zp_food""1""激活购买食物");
}

public 
OnConVarChange(Handle:convar, const String:oldValue[], const String:newValue[])
{
    if(
convar == g_Cvar_FoodEnabled)
    {
        if (
strcmp(oldValuenewValue) != 0)
        {
            if (
strcmp(newValue"1") == 0)
                
SetConVarInt(g_Cvar_FoodEnabledtrue);
            else
                
SetConVarInt(g_Cvar_FoodEnabledfalse);
        }
    }
}

public 
APLRes AskPluginLoad2(Handle myselfbool latechar[] errorint err_max)
{
    
RegPluginLibrary("zp_food");    
    
    
CreateNative("zp_earn_food"native_earn_food);    

    return 
APLRes_Success;
}

public 
native_earn_food(Handle:pluginnumParams)
{
    new 
id GetNativeCell(1);
    return 
purchase_food(id);
}

public 
OnMapStart()
{
    
PrecacheSound("music/zmParadise/mygoodness_fix.mp3");
    
//PrecacheSound("music/zmParadise/AssKnife/predead.mp3");
    
    
AddFileToDownloadsTable("sound/music/zmParadise/mygoodness_fix.mp3");
    
//AddFileToDownloadsTable("sound/music/zmParadise/AssKnife/predead.mp3");
}

public 
Action:Event_RoundEnd(Handleevent , const Stringname[] , booldontBroadcast)
{
    
remove_all_drug();
}

public 
Action:Event_Player_Spawn(Handle:event, const String:Name[], bool:Broadcast)
{
    
remove_all_drug();
}

public 
Action:Event_Player_Death(Handle:event, const String:Name[], bool:Broadcast)
{
    
remove_all_drug();
}

public  
Action:ZR_OnClientInfect(&client, &attacker, &bool:motherInfect, &bool:respawnOverride, &bool:respawn)
{
    if(
client >= && client <= MaxClients)
    {
        if(
IsClientInGame(client) && IsClientConnected(client))
        {
            
kill_drug_task(client);
            
kill_speed_task(client);
        }
    }
}

public 
Action Clcmd_Food(int idArguments)
{
    if(!
IsClientConnected(id))
        return 
Plugin_Continue;
    
    if(!
IsPlayerAlive(id))
        return 
Plugin_Continue;

    
purchase_food(id);
    
    return 
Plugin_Handled;
}

public 
purchase_food(id)
{
    if(
zp_get_user_ammo_packs(id) < 1)
    {
        
CPrintToChat(id"\x01[\x04Food]\x01 보유하신 탄약팩이 부족합니다!");
        return;
    }
    
    if(!
GetConVarInt(g_Cvar_FoodEnabled))
    {
        
CPrintToChat(id"\x01[\x04Food]\x01 %t""Food Disabled");
        return;
    }
    
    
int multiple;
    
    if(
ZR_IsClientZombie(id))
        
multiple 30;
    else
        
multiple 1;

    
int random GetRandomInt(0sizeof(foodamount)-1);
    
int hp foodamount[random] * multiple;
    
    if(
ZR_IsClientHuman(id))
    {
        if(
GetEntProp(idProp_Data"m_iHealth") > 425)
        {
            
CPrintToChat(id"\x01|\x04[Food]\x01 %t""Food Too High");
            return;
        }
    }

    
CPrintToChatAll("\x01|\x04[Food] %t""Food Ate"idfoodname[random], hp);
    
SetEntProp(idProp_Data"m_iHealth"GetEntProp(idProp_Data"m_iHealth") + hp);
    
    if(
foodskills[random] == 1)
    {
        if(
ZR_IsClientHuman(id))
        {
            
CPrintToChatAll("\x01|\x04[Food] %N \x01%t"id"Food Speed");
            
EmitSoundToAll("music/zmParadise/mygoodness_fix.mp3");
            
fm_set_user_maxspeed(id1.4);
            
g_speed_timer[id] = CreateTimer(5.0reset_user_speedid);        
        }
    }
    
    if(
foodskills[random] == 2)
    {
        
CPrintToChatAll("\x01|\x04[Food] %N \x01%t"id"Food Smoke");
        
EmitSoundToAll("music/zmParadise/mygoodness_fix.mp3");
        
fm_set_user_drug(id1);
        
g_drug_timer[id] = CreateTimer(1.0set_drugidTIMER_REPEAT);        
    }
    
zp_set_user_ammo_packs(idzp_get_user_ammo_packs(id) - 1);
}

public 
OnClientDisconnect(id)
{
    
kill_speed_task(id);
    
kill_drug_task(id);
}

public 
Action:reset_user_speed(Handle:Timerid)
{
    
fm_reset_user_maxspeed(id);
    
g_speed_timer[id] = INVALID_HANDLE;
}

public 
Action:set_drug(Handle:Timerid)
{
    static 
timer 0;
    
    if(
timer 5)
    {
        
kill_drug_task(id);
        
fm_set_user_drug(id0);
        return 
Plugin_Stop;
    }
    
    
timer++;
    
fm_set_user_drug(id1);
    return 
Plugin_Continue;
}

public 
kill_speed_task(id)
{
    if(
g_speed_timer[id] != INVALID_HANDLE)
    {
        
fm_reset_user_maxspeed(id);
        
KillTimer(g_speed_timer[id]);
        
g_speed_timer[id] = INVALID_HANDLE;
    }    
}

public 
kill_drug_task(id)
{
    if(
g_drug_timer[id] != INVALID_HANDLE)
    {
        
KillTimer(g_drug_timer[id]);
        
g_drug_timer[id] = INVALID_HANDLE;
    }    
}

stock fm_set_user_maxspeed(idFloat:speed)
{
    if(
ZR_IsClientHuman(id))
    {
        
SetEntPropFloat(idProp_Data"m_flLaggedMovementValue"speed);      
    }
}

stock fm_reset_user_maxspeed(id)
{
    if(
ZR_IsClientHuman(id))    
    {
        
SetEntPropFloat(idProp_Data"m_flLaggedMovementValue"1.0);
    }
}

stock fm_set_user_drug(idint flag)
{
    switch(
flag)
    {
        case 
0:
        {
            new 
Float:angs[3];
            
GetClientEyeAngles(idangs);
            
            
angs[2] = 0.0;
            
            
TeleportEntity(idNULL_VECTORangsNULL_VECTOR);    
            
            new 
clients[2];
            
clients[0] = id;

            new 
duration 1536;
            new 
holdtime 1536;
            new 
flags = (0x0001 0x0010);
            new 
color[4] = { 000};

            
Handle message StartMessageEx(g_FadeUserMsgIdclients1);
            
Protobuf pb UserMessageToProtobuf(message);
            
pb.SetInt("duration"duration);
            
pb.SetInt("hold_time"holdtime);
            
pb.SetInt("flags"flags);
            
pb.SetColor("clr"color);
            
EndMessage();
        }
        case 
1:
        {
            new 
Float:angs[3];
            
GetClientEyeAngles(idangs);
            
            
angs[2] = g_DrugAngles[GetRandomInt(0,100) % 20];
            
            
TeleportEntity(idNULL_VECTORangsNULL_VECTOR);
            
            new 
clients[2];
            
clients[0] = id;    
            
            new 
duration 255;
            new 
holdtime 255;
            new 
flags 0x0002;
            new 
color[4] = { 000128 };
            
color[0] = GetRandomInt(0,255);
            
color[1] = GetRandomInt(0,255);
            
color[2] = GetRandomInt(0,255);

            
Handle message StartMessageEx(g_FadeUserMsgIdclients1);
            
Protobuf pb UserMessageToProtobuf(message);
            
pb.SetInt("duration"duration);
            
pb.SetInt("hold_time"holdtime);
            
pb.SetInt("flags"flags);
            
pb.SetColor("clr"color);
            
EndMessage();
        }
        
        default: return;
    }
}

stock remove_all_drug()
{
    for(
int id=1id<=MaxClientsid++)
    {
        if(
IsClientInGame(id) && IsClientConnected(id))
        {
            new 
Float:angs[3];
            
GetClientEyeAngles(idangs);
            
            
angs[2] = 0.0;
            
            
TeleportEntity(idNULL_VECTORangsNULL_VECTOR);    
            
            new 
clients[2];
            
clients[0] = id;

            new 
duration 1536;
            new 
holdtime 1536;
            new 
flags = (0x0001 0x0010);
            new 
color[4] = { 000};

            
Handle message StartMessageEx(g_FadeUserMsgIdclients1);
            
Protobuf pb UserMessageToProtobuf(message);
            
pb.SetInt("duration"duration);
            
pb.SetInt("hold_time"holdtime);
            
pb.SetInt("flags"flags);
            
pb.SetColor("clr"color);
            
EndMessage();
        }    
    }

[/PHP]
Attached Files
File Type: sp Get Plugin or Get Source (HPfood1.sp - 27 views - 7.6 KB)
wugagagaga is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 11-05-2023 , 05:06   Re: Plugin Help
Reply With Quote #2

PHP Code:
stock void CreateFade(int clientint fade[4], int duration 500int holdtime 0)
{
    
Handle msg StartMessageOne("Fade"clientUSERMSG_RELIABLE|USERMSG_BLOCKHOOKS);
    if(
GetFeatureStatus(FeatureType_Native"GetUserMessageType") == FeatureStatus_Available
    
&& GetUserMessageType() == UM_Protobuf)
    {
        
PbSetInt(msg"duration"duration);        // Fade duration
        
PbSetInt(msg"hold_time"holdtime);    // Fade hold time
        
PbSetInt(msg"flags"0x0001|0x0010);    // What to do
        
PbSetColor(msg"clr"fade);            // Color RGBA
    
}
    else
    {
        
BfWriteShort(msgduration);        // Fade duration
        
BfWriteShort(msgholdtime);        // Fade hold time
        
BfWriteShort(msg0x0001|0x0010);    // What to do
        
BfWriteByte(msgfade[0]);            // Red
        
BfWriteByte(msgfade[1]);            // Green
        
BfWriteByte(msgfade[2]);            // Blue
        
BfWriteByte(msgfade[3]);            // Alpha
    
}
    
EndMessage();

__________________
Grey83 is offline
wugagagaga
Member
Join Date: Aug 2014
Old 11-05-2023 , 12:36   Re: Plugin Help
Reply With Quote #3

thank
wugagagaga is offline
wugagagaga
Member
Join Date: Aug 2014
Old 11-08-2023 , 11:36   Re: Plugin Help
Reply With Quote #4

[Click image for larger version

Name:	20231108233217.png
Views:	27
Size:	16.8 KB
ID:	202143
don t know where it went wron

who can give me the complete encoding file SP?

thank you for your kindness

Last edited by wugagagaga; 11-08-2023 at 11:41.
wugagagaga is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 11-08-2023 , 13:03   Re: Plugin Help
Reply With Quote #5

Quote:
Originally Posted by wugagagaga View Post
don't know where it went wrong
try this

UPD Fixed line 210
__________________

Last edited by Grey83; 11-09-2023 at 10:33.
Grey83 is offline
wugagagaga
Member
Join Date: Aug 2014
Old 11-08-2023 , 20:01   Re: Plugin Help
Reply With Quote #6

Quote:
Originally Posted by Grey83 View Post
try this
Click image for larger version

Name:	20231109.png
Views:	21
Size:	7.9 KB
ID:	202152

zp_level.inc

there are still error
wugagagaga is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 11-08-2023 , 23:59   Re: Plugin Help
Reply With Quote #7

Quote:
Originally Posted by wugagagaga View Post
there are still error
line 210: return ==> return;
__________________
Grey83 is offline
wugagagaga
Member
Join Date: Aug 2014
Old 11-09-2023 , 08:31   Re: Plugin Help
Reply With Quote #8

Quote:
Originally Posted by Grey83 View Post
line 210: return ==> return;
/SourceMod Batch Compiler
// by the SourceMod Dev Team


//// HPfood 1.3.1.sp
//
// C:\Users\Administrator\Desktop\scripting2022\ HPfood 1.3.1.sp(45) : warning 213: tag mismatch (expected "int", got "void")
// C:\Users\Administrator\Desktop\scripting2022\ HPfood 1.3.1.sp(146) : error 130: cannot coerce functions to values
// C:\Users\Administrator\Desktop\scripting2022\ HPfood 1.3.1.sp(146) : error 100: function prototypes do not match
// C:\Users\Administrator\Desktop\scripting2022\ HPfood 1.3.1.sp(153) : error 130: cannot coerce functions to values
// C:\Users\Administrator\Desktop\scripting2022\ HPfood 1.3.1.sp(153) : error 100: function prototypes do not match
//
// 4 Errors.
//
// Compilation Time: 0.22 sec
// ----------------------------------------

Press enter to exit ...


headache /but thank you for your help
wugagagaga is offline
Grey83
Veteran Member
Join Date: Dec 2014
Location: Ukraine
Old 11-09-2023 , 10:33   Re: Plugin Help
Reply With Quote #9

Quote:
Originally Posted by wugagagaga View Post
4 Errors
fixed
Attached Files
File Type: sp Get Plugin or Get Source (HPfood 1.3.2.sp - 17 views - 6.6 KB)
__________________
Grey83 is offline
wugagagaga
Member
Join Date: Aug 2014
Old 11-09-2023 , 11:58   Re: Plugin Help
Reply With Quote #10

Quote:
Originally Posted by Grey83 View Post
fixed
Okay, it's running fine
But it cannot link the ammunition pack
wugagagaga is offline
Reply


Thread Tools
Display Modes

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 06:56.


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