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

Make button to door


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nican
Veteran Member
Join Date: Jan 2006
Location: NY
Old 02-11-2007 , 17:11   Make button to door
Reply With Quote #1

Well, i usually do not like to ask for help, but i am getting desperate

I am trying to make a plugin so a person can make a button to a door... I already tried a variety of things, and most of the times, the server crashes

How this works, this is a menu...
Key 1 = Look at door
Key 2 = Look at button
Key 3 = Finish
hisaim = get_use_aiming(id,hisaim...)
PHP Code:
switch(key){
            case 
0: {
                new 
theclassname[32]
                
entity_get_string(hisaim,EV_SZ_classname,theclassname,32)
                if(
hisaim == extrastuffb[id])
                    
client_print(id,print_chat,"[Nican] A object can not be a door and a button at the same time!")
                else if(!
equal(theclassname,"func_door",9))
                    
client_print(id,print_chat,"[Nican] This item is not a valid door")                
                else
                    
extrastuff[id] = hisaim
            
}
            case 
1: {
                if(
hisaim == extrastuff[id])
                    
client_print(id,print_chat,"[Nican] A object can not be a door and a button at the same time!")
                else 
                
extrastuffb[id] = hisaim
            
}
            case 
2:{
                if(
extrastuff[id] == || extrastuffb[id] == 0){
                    
client_print(id,print_chat,"[Nican] Please do steps 1 and 2 first")
                } else {
                new 
randomnum random_num(1,512)
                
                new 
clas[32]
                
entity_get_string(extrastuffb[id],EV_SZ_classname,clas,32)
                
                if(!
equal(clas,"func_rot_button"))
                    
set_kvd(extrastuffb[id], KV_ClassName"func_rot_button")
                
set_pev(extrastuff[id],pev_targetname,randomnum)
                
set_pev(extrastuffb[id],pev_target,randomnum)                
                }        
            }            
        } 
Thank you
__________________
http://www.nican132.com
I require reputation!
Nican is offline
Send a message via ICQ to Nican Send a message via MSN to Nican
stupok
Veteran Member
Join Date: Feb 2006
Old 02-11-2007 , 18:25   Re: Make button to door
Reply With Quote #2

Try the code below. You shouldn't mix fakemeta and engine. Also, you passed 32 where it should be 31. (0, 1, 2, ..., 31) Target and targetname are strings, not numbers.

Code:
switch(key) {     case 0:     {         new classname[32]         entity_get_string(hisaim, EV_SZ_classname, classname, 31)                 if(hisaim == extrastuffb[id])         {             client_print(id, print_chat, "[Nican] An object can not be a door and a button at the same time!")         }         else if(!equal(classname, "func_door", 9) /*&& !equal(classname, "func_door_rotating", 18)*/)         {             //what about func_door_rotating?             client_print(id, print_chat, "[Nican] This item is not a valid door")         }         else         {             extrastuff[id] = hisaim         }     }     case 1:     {         if(hisaim == extrastuff[id])         {             client_print(id, print_chat, "[Nican] An object can not be a door and a button at the same time!")         }         else if(!hisaim)         {             client_print(id, print_chat, "[Nican] This item is not a valid button")         }         else         {             extrastuffb[id] = hisaim         }     }     case 2:     {         if(extrastuff[id] == 0 || extrastuffb[id] == 0)         {             client_print(id, print_chat, "[Nican] Please do steps 1 and 2 first")         }         else         {             new classname[32]             entity_get_string(extrastuffb[id], EV_SZ_classname, classname, 31)                         if(!equal(classname, "func_rot_button"))             {                 entity_set_string(extrastuffb[id], EV_SZ_classname, "func_rot_button")             }                         //you have to come up with a way to create a new string every time             //so you'll probably want to store the number of buttons created             //random numbers may be repeated, so I don't advise that             entity_set_string(extrastuff[id], EV_SZ_targetname, "string")             entity_set_string(extrastuffb[id], EV_SZ_target, "string")                      }     } }
stupok is offline
Nican
Veteran Member
Join Date: Jan 2006
Location: NY
Old 02-11-2007 , 18:50   Re: Make button to door
Reply With Quote #3

Well.. Thank you VERY MUCH for answering

I do not know for not mix fakemeta & engine, but nothing that I tried worked, so i started to ignore scripting rules

first, on the "equal(classname, "func_door", 9)", i had predicted the _rotating problem, and at first i did put the &&... but i figured that _rotating is just a continuation of func_door and if the equal function just check the first 9 letters, it will also include the _rotating

I made the entity_set_string as you sad, the door became locked but the button is not working...
Do you think I have to delete this old button, and create a new one with the different classname?
__________________
http://www.nican132.com
I require reputation!
Nican is offline
Send a message via ICQ to Nican Send a message via MSN to Nican
stupok
Veteran Member
Join Date: Feb 2006
Old 02-11-2007 , 19:07   Re: Make button to door
Reply With Quote #4

I'm not sure how to change keyvalues properly, but my guess is to use this:

Code:
DispatchKeyValue(extrastuff[id], "targetname", "string") DispatchKeyValue(extrastuffb[id], "target", "string")

instead of this:

Code:
entity_set_string(extrastuff[id], EV_SZ_targetname, "string") entity_set_string(extrastuffb[id], EV_SZ_target, "string")
stupok is offline
Nican
Veteran Member
Join Date: Jan 2006
Location: NY
Old 02-11-2007 , 19:19   Re: Make button to door
Reply With Quote #5

Found the problem I can not change the "classname" of something, I have to create a new object with the new classname
If both items is already a door and a button it works

Thank you...
__________________
http://www.nican132.com
I require reputation!

Last edited by Nican; 02-11-2007 at 19:24.
Nican is offline
Send a message via ICQ to Nican Send a message via MSN to Nican
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 02-12-2007 , 05:00   Re: Make button to door
Reply With Quote #6

Quote:
Originally Posted by stupok69 View Post
I'm not sure how to change keyvalues properly, but my guess is to use this:

Code:
DispatchKeyValue(extrastuff[id], "targetname", "string") DispatchKeyValue(extrastuffb[id], "target", "string")

instead of this:

Code:
entity_set_string(extrastuff[id], EV_SZ_targetname, "string") entity_set_string(extrastuffb[id], EV_SZ_target, "string")
Code:
set_pev(extrastuff[id], pev_targetname, "string") set_pev(extrastuffb[id], pev_target, "string")
[ --<-@ ] Black Rose 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 01:50.


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