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

Hero problem!


Post New Thread Reply   
 
Thread Tools Display Modes
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 05-10-2011 , 15:28   Re: Hero problem!
Reply With Quote #21

PHP Code:
if ( get_user_weapon(id) == CSW_GALIL
{
    
//set galil model here
}

else if ( 
get_user_weapon(id) == CSW_DEAGLE )
{
    
//set deagle model here

__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
DarkGod
SourceMod DarkCrab
Join Date: Jul 2007
Location: Sweden
Old 05-10-2011 , 15:41   Re: Hero problem!
Reply With Quote #22

Quote:
Originally Posted by Jelle View Post
The way it is now it just checks if user has galil and does nothing, and if user has deagle it sets both deagle and galil model on the deagle.
That's actually wrong. Right now it does this:

Code:
if(get_user_weapon(index) == CSW_GALIL) {    if(get_user_weapon(index) == CSW_DEAGLE)    {       //Code    } }

Anyways, the snippet you provided afterwards is correct.
__________________
DarkGod is offline
Send a message via AIM to DarkGod Send a message via MSN to DarkGod
Fr33m@n
Veteran Member
Join Date: May 2008
Location: France Marne
Old 05-10-2011 , 16:05   Re: Hero problem!
Reply With Quote #23

switch is the way to go here. I don't know why people never think to use it.

Last edited by Fr33m@n; 05-10-2011 at 16:09.
Fr33m@n is offline
DarkGod
SourceMod DarkCrab
Join Date: Jul 2007
Location: Sweden
Old 05-10-2011 , 16:15   Re: Hero problem!
Reply With Quote #24

Quote:
Originally Posted by Fr33m@n View Post
switch is the way to go here. I don't know why people never think to use it.
Never? Most people do use it. It's barely any advantage in efficiency anyways. It's good practice, sure, but you exaggerate.
__________________
DarkGod is offline
Send a message via AIM to DarkGod Send a message via MSN to DarkGod
Fr33m@n
Veteran Member
Join Date: May 2008
Location: France Marne
Old 05-10-2011 , 16:23   Re: Hero problem!
Reply With Quote #25

i'm talking about here : Jelly Art Exploited and so on.
I obviously know that switch is used a lot. But here...

Last edited by Fr33m@n; 05-10-2011 at 16:26.
Fr33m@n is offline
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 05-10-2011 , 18:19   Re: Hero problem!
Reply With Quote #26

Quote:
Originally Posted by DarkGod View Post
switch_model(id)
{
if (!
sh_is_active() || !is_user_alive(id) || !gHasBones[id] ) return

if (
get_user_weapon(id) == CSW_GALIL)
if (
get_user_weapon(id) == CSW_DEAGLE)
{
set_pev(id, pev_viewmodel2, gBonesGalil)
set_pev(id, pev_weaponmodel2, gBonesGalil2)
set_pev(id, pev_viewmodel2, gBonesDeagle)
set_pev(id, pev_weaponmodel2, gBonesDeagle2)
}
}

You can't have two weapons up at the same time. Use else if.
Quote:
Originally Posted by DarkGod View Post
That's actually wrong. Right now it does this:

Code:
if(get_user_weapon(index) == CSW_GALIL) { if(get_user_weapon(index) == CSW_DEAGLE) { //Code } }


Anyways, the snippet you provided afterwards is correct.
I can't see an opening brace after the check for the galil weapon, so if user has galil, nothing happens. Or is there an automatically opening brace when you do an if condition? Not really sure about that, since using a return on the next line works. Weird, never though of that.

Quote:
Originally Posted by Fr33m@n View Post
i'm talking about here : Jelly Art Exploited and so on.
I obviously know that switch is used a lot. But here...
MY NAME IS JELLE, NOT JELLY!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!

Also, I do use switch, but only when there is more than two if conditions.
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
DarkGod
SourceMod DarkCrab
Join Date: Jul 2007
Location: Sweden
Old 05-10-2011 , 19:15   Re: Hero problem!
Reply With Quote #27

Quote:
Originally Posted by Jelle View Post
I can't see an opening brace after the check for the galil weapon, so if user has galil, nothing happens. Or is there an automatically opening brace when you do an if condition? Not really sure about that, since using a return on the next line works. Weird, never though of that.
You can do a function like this:

Code:
function(index)     if(something == true)        DoThis()     else if(something else == false)        if(whatever == false)           DoThat()        else           DoSomething()    else       DoWhatever()

indenting is a bit off, lol, I just did this in the browser.
__________________
DarkGod is offline
Send a message via AIM to DarkGod Send a message via MSN to DarkGod
MuzzMikkel
Member
Join Date: Aug 2010
Location: Denmark
Old 05-11-2011 , 02:00   Re: Hero problem!
Reply With Quote #28

I used your method Jelle but the models still not working? I did like this:

PHP Code:
switch_model(id)
{
    if (!
sh_is_active() || !is_user_alive(id) || !gHasBones[id] ) return
    
if ( 
get_user_weapon(id) == CSW_GALIL
{
        
set_pev(idpev_viewmodel2gBonesGalil)
    
set_pev(idpev_weaponmodel2gBonesGalil2)
}

else if ( 
get_user_weapon(id) == CSW_DEAGLE )
{
    
set_pev(idpev_viewmodel2gBonesDeagle)
    
set_pev(idpev_weaponmodel2gBonesDeagle2)
    }

Can you fix the problem?
MuzzMikkel is offline
Send a message via MSN to MuzzMikkel
MuzzMikkel
Member
Join Date: Aug 2010
Location: Denmark
Old 05-11-2011 , 02:14   Re: Hero problem!
Reply With Quote #29

Quote:
Originally Posted by DarkGod View Post
That's actually wrong. Right now it does this:

Code:
if(get_user_weapon(index) == CSW_GALIL) {    if(get_user_weapon(index) == CSW_DEAGLE)    {       //Code    } }

Anyways, the snippet you provided afterwards is correct.
When i try your method it dosen't work either, the compiler say:


Code:
<115> : error 017: undefined symbol "index"
<117> : error 017: undefined symbol "index"
MuzzMikkel is offline
Send a message via MSN to MuzzMikkel
Jelle
[b]MOAR CANDY[/b]
Join Date: Aug 2009
Location: Denmark
Old 05-11-2011 , 02:16   Re: Hero problem!
Reply With Quote #30

Quote:
Originally Posted by DarkGod View Post
You can do a function like this:

Code:
function(index) if(something == true) DoThis() else if(something else == false) if(whatever == false) DoThat() else DoSomething() else DoWhatever()


indenting is a bit off, lol, I just did this in the browser.
I wasn't really aware of that, thank you.

Quote:
Originally Posted by MuzzMikkel View Post
I used your method Jelle but the models still not working? I did like this:

PHP Code:
switch_model(id)
{
    if (!
sh_is_active() || !is_user_alive(id) || !gHasBones[id] ) return
    
if ( 
get_user_weapon(id) == CSW_GALIL
{
        
set_pev(idpev_viewmodel2gBonesGalil)
    
set_pev(idpev_weaponmodel2gBonesGalil2)
}

else if ( 
get_user_weapon(id) == CSW_DEAGLE )
{
    
set_pev(idpev_viewmodel2gBonesDeagle)
    
set_pev(idpev_weaponmodel2gBonesDeagle2)
    }

Can you fix the problem?
Post the whole code. Have you precached the weapon model correct?
__________________
No idea what to write here...
Jelle is offline
Send a message via MSN to Jelle
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 03:22.


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