Raised This Month: $ Target: $400
 0% 

3 scripting questions


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Adam108
Junior Member
Join Date: Jul 2013
Old 09-22-2013 , 02:23   3 scripting questions
Reply With Quote #1

I have some questions:

1. What means warning "tag mismatch"?
2. Can I restrict buying weapons without restricting the buyzone?
3. How can i find out, that user changed team? (I know about register_clcmd("jointeam","blabla")), but doesn't work allways wlll)

sorry for my english

Last edited by Adam108; 09-22-2013 at 02:24.
Adam108 is offline
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 09-22-2013 , 03:09   Re: 3 scripting questions
Reply With Quote #2

1. You declare something wrong, search the forums. I can't tell you why do you receive the error without the code.
2. client_buy forward by ConnorMcLeod.
3. You can return player's team, using cs_get_user_team() or simply get_user_team().
__________________




Last edited by dark_style; 09-22-2013 at 03:10.
dark_style is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-22-2013 , 04:27   Re: 3 scripting questions
Reply With Quote #3

1. The tag doesn't match the definition of the variable.
3. Why do you think it doesn't work well? You'll need to learn that it is best to tell us what exactly you are trying to do when asking for any sort of help (and not ask for help on something that you 'think' is the solution).
__________________
fysiks is offline
Adam108
Junior Member
Join Date: Jul 2013
Old 09-22-2013 , 06:17   Re: 3 scripting questions
Reply With Quote #4

Here's the plugin: (I'm trying to create my TF mode )
PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <cstrike>
#include <chatcolor>
#include <fun>

#define PLUGIN "Team fortress basic"
#define VERSION "1.0"
#define AUTHOR "Adam108"

#define CLASSLIMIT 3

new const classes[][] = {
    
"Unassigned",
    
"Scout",
    
"Soldier",
    
"Sharpshooter",
    
"Demoman",
    
"Heavy",
    
"Engineer",
    
"Medic",
    
"Sniper"
}
new const 
Float:speeds[] = {
    
"1.0"//on these lines are the mismatches
    
"1.5",
    
"1.1",
    
"1.1",
    
"0.8",
    
"0.7",
    
"1.1",
    
"1.1",
    
"1.1"
}
new const 
healths[] = {
    
"100",
    
"130",
    
"150",
    
"140",
    
"140",
    
"250",
    
"150",
    
"160",
    
"140"
}
new const 
armors[] = {
    
"0",
    
"100",
    
"150",
    
"140",
    
"160",
    
"200",
    
"150",
    
"100",
    
"100"
}
new 
classcountT[9]
new 
classcountCT[9]

new class[
33]

stock joinclass(id,jclass,team) {
    if(class[
id]) { //If user has already joined in some class...
        
switch(team) {
            case 
1classcountT[class[id]]--
            case 
2classcountCT[class[id]]--
        }
    }
    class[
id] = jclass
    color_chat
(id,"!g[TF] !yYou've become a !team%s!y!",classes[jclass])
/*    switch(jclass) {
        case 1:
    }*/
}
public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
RegisterHam(Ham_Spawn,"player","UserSpawn",1)
    
    
register_clcmd("say /class","ClassChange",1)
    
register_clcmd("say /team","cmdTeamInfo")
    
    
register_clcmd("jointeam","cmdJointeam")
    
register_clcmd("drop","cmdDrop")
}
public 
client_disconnect(id) {
    if(class[
id]) {
        switch(
cs_get_user_team(id)) {
            case 
1classcountT[class[id]]--
            case 
2classcountCT[class[id]]--
        }
    }
    class[
id] = 0
}
public 
cmdDrop(id)
    return 
PLUGIN_HANDLED
public cmdJointeam(id) {
    if(class[
id]) {
        class[
id] = 0
        color_chat
(id,"!g[TF] !yYou've been kicked out of your class because you changed your team!")
    }
    return 
PLUGIN_CONTINUE
}
public 
UserSpawn(id) {
    
color_chat(0,"test %i",id)
    
strip_user_weapons(id)
    
give_item(id,"weapon_knife")
    if(!class[
id]) {
        
ClassChange(id,2)
        return 
HAM_IGNORED
    
}
    
set_user_maxspeed(id,speeds[class[id]]) //These lines don't work well...
    
set_user_health(id,healths[class[id]]) //They sets strenge value of healths atd.
    
cs_set_user_armor(id,armors[class[id]],CS_ARMOR_VESTHELM)
/*    switch(class[id]) {
        case 1: {
            
        }
        case 2: {
            
        }
        case 3: {
            
        }
        case 4: {
            
        }
        case 5: {
            
        }
        case 6: {
            
        }
        case 7: {
            
        }
        case 8: {
            
        }
    } */
    
return HAM_IGNORED
}
public 
ClassChange(id,type) {
    new 
ClassMenu menu_create("Choose your class:","ClassMenu_Handler")
    
menu_setprop(ClassMenu,MPROP_PERPAGE,0)
    for(new 
a=1;a<9;a++)
        
menu_additem(ClassMenu,classes[a])
    
menu_addblank(ClassMenu,1)
    
menu_additem(ClassMenu,"Close")
    
menu_display(id,ClassMenu)
    if(
type==1)
        return 
PLUGIN_HANDLED
    
else
        return
}
public 
ClassMenu_Handler(id,menu,item) {
    
menu_destroy(menu)
    if(
item==MENU_EXIT) {
        if(!class[
id])
            return 
ClassChange(id,1)
        else
            return 
PLUGIN_HANDLED
    
}
    
item++
    if(class[
id]==item) {
        
color_chat(id,"!g[TF] !yYou've already joined this class!")
        return 
PLUGIN_HANDLED
    
}
    new 
team cs_get_user_team(id)
    switch(
team) {
        case 
1: {
            if(
classcountT[item] < CLASSLIMIT) {
                
classcountT[item]++
                
joinclass(id,item,team)
            }
            else
            {
                
color_chat(id,"!g[TF] !yYou can't join this class now!")
                return 
PLUGIN_HANDLED
            
}
            
        }
        case 
2: {
            if(
classcountCT[item] < CLASSLIMIT) {
                
classcountCT[item]++
                
joinclass(id,item,team)
            }
            else
            {
                
color_chat(id,"!g[TF] !yYou can't join this class now!")
                return 
PLUGIN_HANDLED
            
}
        }
    }
    if(!
is_user_alive(id))
        return 
PLUGIN_HANDLED
    
if(!cs_get_user_buyzone(id))
        
user_kill(id)
    else
        return 
UserSpawn(id)
    return 
PLUGIN_HANDLED
}
public 
cmdTeamInfo(id) {
    new 
message[192]
    new 
team cs_get_user_team(id)
    if(
team==|| !team) {
        
color_chat(id,"!g[TF] !yYou aren't in any team!")
        return 
PLUGIN_HANDLED
    
}
    
add(message,191,"!g[TF] !yClasses in your team:")
    switch(
team) {
        case 
1: for(new a=1;a<9;a++) {
                if(
classcountT[a])
                    
format(message,191,"%s %s: %i",message,classes[a],classcountT[a])
            }
        case 
2: for(new a=1;a<9;a++) {
                if(
classcountCT[a])
                    
format(message,191,"%s %s: %i",message,classes[a],classcountCT[a])
            }
    }
    
color_chat(id,"%s",message)
    return 
PLUGIN_HANDLED

Adam108 is offline
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 09-22-2013 , 07:09   Re: 3 scripting questions
Reply With Quote #5

http://forums.alliedmods.net/showthread.php?t=187025 - Constants part.
__________________



dark_style is offline
Adam108
Junior Member
Join Date: Jul 2013
Old 09-22-2013 , 07:31   Re: 3 scripting questions
Reply With Quote #6

But I don't know why I have a problem with my plugin. It is hard to rapair my plugin if i don't know the cause
Adam108 is offline
Black Rose
Veteran Member
Join Date: Feb 2011
Location: Stockholm, Sweden
Old 09-22-2013 , 07:59   Re: 3 scripting questions
Reply With Quote #7

You're trying to assigns strings to a float variable.
Remove the quotes around the numbers in speeds, healths and armors.
__________________
Black Rose is offline
Adam108
Junior Member
Join Date: Jul 2013
Old 09-22-2013 , 09:21   Re: 3 scripting questions
Reply With Quote #8

Thanks, it's working now
One more question: If i create a mode that includes foreign plugins (for example sentryguns, dispensers...), have i to ask the authors of those plugins or is it enough when i mention that autor is Mr. XY?

sorry for my english
Adam108 is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 09-22-2013 , 15:03   Re: 3 scripting questions
Reply With Quote #9

Quote:
Originally Posted by Adam108 View Post
Thanks, it's working now
One more question: If i create a mode that includes foreign plugins (for example sentryguns, dispensers...), have i to ask the authors of those plugins or is it enough when i mention that autor is Mr. XY?

sorry for my english
You can use their code without asking but it's a very good thing if you mention their name and that the particular section was written by them. I would even document it in the code with a comment and possibly a link to the source code of the plugin that you are using.
__________________
fysiks is offline
Adam108
Junior Member
Join Date: Jul 2013
Old 09-24-2013 , 07:05   Re: 3 scripting questions
Reply With Quote #10

Thanks
Im sorry, i have two next questions
How can i get the part of body, where the player was hitted? And how can i get the weapon, that was the damge caused by?
How can i restrict earning money?
Adam108 is offline
Old 09-24-2013, 07:33
wickedd
This message has been deleted by wickedd.
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 18:54.


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