AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   3 scripting questions (https://forums.alliedmods.net/showthread.php?t=226716)

Adam108 09-22-2013 02:23

3 scripting questions
 
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

dark_style 09-22-2013 03:09

Re: 3 scripting questions
 
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().

fysiks 09-22-2013 04:27

Re: 3 scripting questions
 
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).

Adam108 09-22-2013 06:17

Re: 3 scripting questions
 
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



dark_style 09-22-2013 07:09

Re: 3 scripting questions
 
http://forums.alliedmods.net/showthread.php?t=187025 - Constants part.

Adam108 09-22-2013 07:31

Re: 3 scripting questions
 
But I don't know why I have a problem with my plugin. :D It is hard to rapair my plugin if i don't know the cause :D

Black Rose 09-22-2013 07:59

Re: 3 scripting questions
 
You're trying to assigns strings to a float variable.
Remove the quotes around the numbers in speeds, healths and armors.

Adam108 09-22-2013 09:21

Re: 3 scripting questions
 
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

fysiks 09-22-2013 15:03

Re: 3 scripting questions
 
Quote:

Originally Posted by Adam108 (Post 2039053)
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.

Adam108 09-24-2013 07:05

Re: 3 scripting questions
 
Thanks :)
Im sorry, i have two next questions :D
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?


All times are GMT -4. The time now is 18:54.

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