Raised This Month: $ Target: $400
 0% 

[CS:GO] Need help scripting!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
klaus65
Member
Join Date: Feb 2011
Old 09-10-2013 , 12:29   [CS:GO] Need help scripting!
Reply With Quote #1

Hey,
How do I make this in sourcemod (for cs:go)
from cs 1.6 plugin:
PHP Code:
public plugin_init() 
{
    
register_event("CurWeapon","CurWeapon","be""1=1");
}

public 
CurWeapon(id)
{
    if(
freezetime || !class_player[id])
        return 
Plugin_Continue;
        
    new 
weapon read_data(2);

    
SetFast(id);
    
    if(
weapon == CSW_C4)
        
bomber id;
    return 
Plugin_Continue;

Thanks!
klaus65 is offline
ALKINDA
Member
Join Date: Aug 2013
Old 09-10-2013 , 13:15   Re: [CS:GO] Need help scripting!
Reply With Quote #2

Quote:
Originally Posted by klaus65 View Post
Hey,
How do I make this in sourcemod (for cs:go)
from cs 1.6 plugin:
PHP Code:
public plugin_init() 
{
    
register_event("CurWeapon","CurWeapon","be""1=1");
}

public 
CurWeapon(id)
{
    if(
freezetime || !class_player[id])
        return 
Plugin_Continue;
        
    new 
weapon read_data(2);

    
SetFast(id);
    
    if(
weapon == CSW_C4)
        
bomber id;
    return 
Plugin_Continue;

Thanks!
simple description on what its supposed to do would be nice lol.
__________________
ALKINDA is offline
Taz532
Senior Member
Join Date: Jul 2011
Location: Michigan
Old 09-10-2013 , 17:03   Re: [CS:GO] Need help scripting!
Reply With Quote #3

Well here's a translation of that code, but the snippet you posted wasn't a complete plugin so obviously the translation isn't either. If this is all you needed, great. If not, let us know what it's supposed to do (or post the entire plugin) and we can take it from there.

PHP Code:
public OnPluginStart()
{
    
HookEvent("item_equip"event_item_equip);
}

public 
Action:event_item_equip(Handle:event, const String:name[], bool:dontBroadcast

    new 
client GetClientOfUserId(GetEventInt(event"userid"));
    if (
freezetime || !class_player[client])
        return 
Plugin_Continue;
    
    
SetFast(client)
    
    new 
weapon GetEventInt(event"weptype");
    if (
weapon == 7//WEAPONTYPE_C4
        
bomber client;
    return 
Plugin_Continue;


Last edited by Taz532; 09-10-2013 at 17:05.
Taz532 is offline
klaus65
Member
Join Date: Feb 2011
Old 09-11-2013 , 06:16   Re: [CS:GO] Need help scripting!
Reply With Quote #4

Do you think I should use that or OnWeaponSwitch if I want it to check every time someone changes weapon? BTW random questions pls answer! what means ! and ? on scripts. how about difference between Plugin_Handled and Plugin_Continue.. and why do some use only return or return 0? what do those mean?
klaus65 is offline
TheGodKing
BANNED
Join Date: Dec 2012
Location: PrintToChatAll("Aus
Old 09-11-2013 , 07:11   Re: [CS:GO] Need help scripting!
Reply With Quote #5

Plugin_Handled tells the plugin to halt all code in a given function including normal game events should there be any.
Plugin_Continue tells the plugin to halt all code, but allow game events to function normally.
! is the Logical NOT operator which can be used to check if something is not equal to something. (comparison)
? is a conditional operator that returns a value if the expression is true and another if it's false.



Plugin_Handled - AwesomeCode will not run, nor will normal game events that this function covers.

PHP Code:
Function()
{
    return 
Plugin_Handled// Ends Function() unless nested under a statement
    
    
AwesomeCode(client);

Plugin_Continue - AwesomeCode will not run if a client is fake, if a client is real they will skip the check straight to our function.
At the same time the normal game events covered by this function will run for real and fake clients.

PHP Code:
Function()
{
    if ( 
IsFakeClient(client) ) // Is the client fake?
        
return Plugin_Continue;
    
    
AwesomeCode(client);

! - Here we are checking if a client is not fake using the ! operator and executing our function.
This function will now perform the opposite of the above code.

PHP Code:
Function()
{
    if ( ! 
IsFakeClient(client) ) // Is the client real?
        
return Plugin_Continue;
        
    
AwesomeCode(client);

? - Here we are checking if a is equal to b which is false, so we will end up with result2.

PHP Code:
Example 1:

Function()
{
    
10
    b 
100
    
    a 
== result1 result2 // We will end up with result2
}



Example 2:

Function()
{
    
555
    b 
555
    
    a 
== result1 result2 // We will end up with result1

If someone finds what I've posted to be wrong please correct what I've said.

Last edited by TheGodKing; 09-11-2013 at 07:12.
TheGodKing is offline
klaus65
Member
Join Date: Feb 2011
Old 09-11-2013 , 09:10   Re: [CS:GO] Need help scripting!
Reply With Quote #6

Thanks!, really well explained +++
klaus65 is offline
Taz532
Senior Member
Join Date: Jul 2011
Location: Michigan
Old 09-11-2013 , 14:49   Re: [CS:GO] Need help scripting!
Reply With Quote #7

Oh yea OnWeaponSwitch is probably better. I didn't even know it existed, but I've used item_equip for something similar to this before and it worked though.
Taz532 is offline
klaus65
Member
Join Date: Feb 2011
Old 09-11-2013 , 15:49   Re: [CS:GO] Need help scripting!
Reply With Quote #8

Please dont answer: "Try it" because I cant right now!
Can I do this to heal whole team? this is part from shopmenu:
Quote:
if(IsClientConnected() && IsPlayerAlive() && GetClientTeam() = GetClientTeam(id))
{
new healed_hp = (maximum_health_player[]-GetClientHealth() <=50)
SetEntityHealth(entity, GetClientHealth()+healed_hp);
}
Thanks!

Last edited by klaus65; 09-11-2013 at 15:49.
klaus65 is offline
Taz532
Senior Member
Join Date: Jul 2011
Location: Michigan
Old 09-11-2013 , 17:55   Re: [CS:GO] Need help scripting!
Reply With Quote #9

No that won't work. How you'd approach it depends on what you're trying to do, but if the healing of the team is fired by a person on that team, then you could do something like this...

PHP Code:
new team GetClientTeam(client); //get the activator's team
new healed_hp 50//50 for now because im not actually sure what the other thing was supposed to do
for (new 1<= MaxClientsi++) //loop through all clients
{
    if (!
IsClientConnected(i)) continue; //client not connected, ignore him
    
if (GetClientTeam(i) == team//same team check
    
{
        if (
IsPlayerAlive(i)) //Player alive check
        
{
            
SetEntityHealth(iGetClientHealth(i)+healed_hp); //Set the health
        
}
    }

This assumes that you have client already identified in the function you put this in. Also, this won't heal a player past 100hp. To do that you have to manually set their maxhealth to something higher than 100. And if you want the healed_hp changed to something else then tell me what its supposed to do.

Last edited by Taz532; 09-11-2013 at 17:56. Reason: Forgot a semicolon
Taz532 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 12:23.


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