Raised This Month: $ Target: $400
 0% 

Keeping speed


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EpicKiller
Senior Member
Join Date: Jun 2014
Location: Constanta, Romania
Old 07-07-2014 , 05:25   Keeping speed
Reply With Quote #1

Hello! I have started learning scripting some time ago, but I never really tried scripting stuff from scratch. Well, the last few days I have. So, I am now trying to do a Deathrun VIP plugin, as I wish using my own one. What it is suposed to do: /vip - gives a VIP 600 speed. /vipoff - sets the VIP's speed back to default. I got that figured easily. Too bad I can't seem to figure out how to get it to stay. I mean... remain 600 after changing the weapon. Also, the plugin should set VIPS skins. I don't yet know if that is going to happen, as I did not get to test the skins part.

So if you could please look in my code... So what I need is that speed stabillity. Plus, I'd really appreciate it if you could also check my code for setting those skins, ah I have no idea if I did it right.
Oh, and one other question: what's the difference between setting the user's speed by pev_maxspeed or by set_user_maxspeed? Is one of them more appropriate?

Thank you so much for your help!

PS: Please go easy on me, I'm a rookie.

Here's my code:
EpicKiller is offline
Send a message via Yahoo to EpicKiller Send a message via Skype™ to EpicKiller
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 07-07-2014 , 07:20  
Reply With Quote #2

You need to hold the state of speed in a variable and regive the speed eighter (and this is recommended) with hamsandwich or (don't use this) with the CurWeapon-Event.

Have a look:
PHP Code:
new hasSpeed[33]

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
RegisterHam(Ham_CS_Player_ResetMaxSpeed"player""hamResetSpeedPost"true)
}

public 
hamResetSpeedPost(id)
{
    if(
hasSpeed[id])
    {
        
set_user_maxspeed(id600.0)
    }
}

public 
cmdVip(id)
{
    if(
get_user_flags(id) & VIP_LEVEL)
    {
        
hasSpeed[id] = 1
        set_user_maxspeed
(id600.0);
        
client_print(idprint_chat"You just activated your VIP attributes.");
        
client_print(idprint_chat"Just write /vipoff to switch them off.");
    }
    else
    {
        
client_print(idprint_chat"You're no VIP!");
    }
}

public 
cmdVipoff(id)
{
    if(
get_user_flags(id) & VIP_LEVEL)
    {
        
hasSpeed[id] = 0
        set_user_maxspeed
(id250.0);
        
client_print(idprint_chat"You just deactivated your VIP attributes.");
        
client_print(idprint_chat"Just write /vip to switch them back on.");
    }

For the skins thing:
You need to hook the spawn event (using hamsandwich) and then set the model. Also you don't need to precache your files twice.

Btw:
- Using a switch statement is bether than multiple if statements (line 65-72)
- You forgot the if-braces (line 47)
- pev_maxspeed vs set_user_maxspeed: This is pretty much a question of preference and modules. If you already include Fakemeta you could aswell use the pev-things and skip the Fun-module.

Last edited by mottzi; 07-07-2014 at 07:29.
mottzi is offline
Send a message via MSN to mottzi
EpicKiller
Senior Member
Join Date: Jun 2014
Location: Constanta, Romania
Old 07-07-2014 , 09:11   Re: Keeping speed
Reply With Quote #3

Thank you so much! I successfully (or I think I have) coded the skins part. But the spawn part... not so much. It returns few compilation errors ans warning. All of them on the same line, which is 24.

Please, could you further help me?

This is what I got now.
EpicKiller is offline
Send a message via Yahoo to EpicKiller Send a message via Skype™ to EpicKiller
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 07-07-2014 , 09:40   Re: Keeping speed
Reply With Quote #4

Post the error / warning messages here. Do you use the 1.8.3 version of amxx? Because IIRC Ham_CS_Player_ResetMaxSpeed was only added there.
mottzi is offline
Send a message via MSN to mottzi
EpicKiller
Senior Member
Join Date: Jun 2014
Location: Constanta, Romania
Old 07-07-2014 , 15:55   Re: Keeping speed
Reply With Quote #5

Quote:
Originally Posted by mottzi View Post
Post the error / warning messages here. Do you use the 1.8.3 version of amxx? Because IIRC Ham_CS_Player_ResetMaxSpeed was only added there.
Yes, the errors were indeed about the Ham_CS_Player_ResetMaxSpeed function, being declared as unknown by the compiler. Well, my compiler is 1.8.1, fact that I was not aware of. But, as I can see, the online compiler on amxmodx.org is also 1.8.1, so I guess I will just have to find a 1.8.3 compiler. Apparently, I have 1.8.1 installed on my servers too. I wasn't even aware of that, I thought I got the latest version.

A couple of minutes later: Good, I have downloaded the latest version of AMXX. My plugin is now compiled. I will edit my post the second I have it tested, just let me install the latest version on my server too.

Last edited by EpicKiller; 08-12-2014 at 05:00.
EpicKiller is offline
Send a message via Yahoo to EpicKiller Send a message via Skype™ to EpicKiller
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 21:14.


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