View Full Version : How to add a bot?
Hello there,
how do i add a bot to the game? Ive tried that:
public addBot(const String:name[], team)
{
new bot = CreateFakeClient(name);
ChangeClientTeam(bot,team);
CS_RespawnPlayer(bot);
}That works, but the bot doesnt move.
Another problem is, CS_RespawnPlayer function makes my plugin fixed to cstrike. Any suggestions?
hmm…
ServerCommand(«bot_join_after_player 0»);
ServerCommand(«bot_add»);
NeoDement
04-18-2009, 14:38
You’d have to enable cheats too though
hmmmm… possible. But how do i set the bots name?
I hoped i could override the bot_quota cvar — the bots added with CreateFakeClient do not get removed when setting bot_quota to 0 (the sever should NEVER add a bot himself).
Moreover i get the bot id when i add a bot with CreateFakeClient, so i can set some more things on it.
BTW: Why is there an API if its not useable at all?
Bots in CS:S work without sv_cheats.
«bot_add»
game
— bot_add <t|ct> <type> <difficulty> <name> — Adds a bot matching the given criteria.
NeoDement
04-18-2009, 14:40
BTW: Why is there an API if its not useable at all?
It can’t do one specific thing, therefore making it entirely unuseable?
Also «bot_add» command is not connected with «bot_quota» I think.
Also «bot_add» command is not connected with «bot_quota».
It is. When i use «bot_add» the «bot_quota» gets incremented. Also, when i set bot_quota to 0, all bots get kicked.
@NeoDement: this is the fourth method i tried to use from the API that doesnt work as i expected. Maybe iam trying to do the wrong things
@exvel: What is the <type> parameter of bot_add?
What is the <type> parameter of bot_add?
I don’t know. Just try different random numbers. Maybe it is a player’s class (model). Try to set it to 0,1,2,3… etc
Ok… ive already done that, thats the reason why i asked how to set the name.
bot_add t 2 2 test
Error — no profile for ‘test’ exists.No matter what i use as parameters, i always get that message
NeoDement
04-18-2009, 15:06
How about bot_add t 0 0 0
Ok… ive already done that, thats the reason why i asked how to set the name.
bot_add t 2 2 test
Error — no profile for ‘test’ exists.No matter what i use as parameters, i always get that message
LOL this is really funny. Valve makes our live harder sometimes without any reason.
Try this:
ServerCommand(«bot_add t»);
than find bot’s client index and do:
FakeClientCommandEx(client_index_of_bot, «name MyNameIsBot»);
deadbwoy
04-19-2009, 18:50
In «cstrike»
there is a file called «botprofile.db»
I bet there is no bot named «test» in that file, if your client even has it…
(might need to extract that file from the .gcf)
Here it is. But I didn’t find anything useful inside.
deadbwoy
06-11-2009, 13:38
Here it is. But I didn’t find anything useful inside.
using the command: bot_add t 2 2 test
you’re trying to tell the game to load the bot profile named «Test»
which doesn’t exist in the default botprofile.db
go into botprofile.db and scroll down to:
Elite+Rifle Cliffe
Skin = 1
VoicePitch = 95
End
Either rename «Cliffe» to «test»
or just use «bot_add t 2 2 Cliffe» if you’d rather not edit the botprofile.db
be sure not to save it as botprofile.txt or botprofile.db.txt
almcaeobtac
06-11-2009, 17:23
Ive been trying to do the same thing. The bots i spawn don’t move, so tell me if you have any luck.
vBulletin® v3.8.7, Copyright ©2000-2023, vBulletin Solutions, Inc.
I have a few maven profiles in my pom.xml. I have jenkins configured to run nightly tests for each of these profiles.
I figured today that there was a spelling mistake in one of the profile names in my jenkins config. Turns out that if maven cannot file a profile, it runs the default profile.
Is there a way I can force maven to throw an error if the profile doesn’t exist?
asked Apr 2, 2014 at 18:56
Maven Enforcer Plugin version 3.0.0-M2 has introduced a built-in check requireProfileIdsExist for this purpose:
When running Maven with one or more unknown profile ids, Maven will give you a warning. This rule will actually break the build for that reason.
Here is how a project should be setup to use this rule
<project> ... <build> <plugins> ... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-enforcer-plugin</artifactId> <version>3.0.0-M2</version> <executions> <execution> <id>enforce</id> <configuration> <rules> <requireProfileIdsExist/> </rules> </configuration> <goals> <goal>enforce</goal> </goals> </execution> </executions> </plugin> ... </plugins> </build> ... </project>
answered Oct 5, 2018 at 12:08
Alex ShesterovAlex Shesterov
25.3k12 gold badges82 silver badges102 bronze badges
answered Apr 9, 2014 at 20:27
AlfAlf
2,2811 gold badge27 silver badges34 bronze badges
You can check if a profile exists without configuring Maven Enforcer Plugin in the pom.xml:
> mvn enforcer:enforce -Drules=requireProfileIdsExist -PprofileToCheck
...
[WARNING] The requested profile "profileToCheck" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:3.0.0:enforce (default-cli) on project idegen: Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed. -> [Help 1]
answered Apr 19, 2022 at 21:50
TyutyutyuTyutyutyu
1411 silver badge6 bronze badges
У меня возникают проблемы при отправке данных из формы на сервер. Я создал API в backend в api/userprofile, и я могу успешно создать профиль, используя POSTMAN. Но при попытке использовать front-end/browser я получаю сообщение об ошибке:
POST http://localhost:3000/api/userprofile 401 (Unauthorized)
Другие ошибки:
index.js:2178 Warning: Failed prop type: Invalid prop 'errors' of type 'string' supplied to 'CreateProfile', expected 'object'.
in CreateProfile (created by Route)
in Route (created by withRouter(CreateProfile))
in withRouter(CreateProfile) (created by Connect(withRouter(CreateProfile)))
in Connect(withRouter(CreateProfile)) (created by Route)
in Route (at App.js:41)
in div (at App.js:37)
in div (at App.js:34)
in Router (created by BrowserRouter)
in BrowserRouter (at App.js:33)
in Provider (at App.js:32)
in App (at index.js:8)
API/userprofile.js
const express = require('express');
const router = express.Router();
const mongoose=require('mongoose');
const passport=require('passport');
//loading validation after creating the userprofie valdiation
const validateProfileInput=require('../../validation/userprofile');
const validateExperienceInput=require('../../validation/experience');
//bring profile schema model
const Profile=require('../../models/Profile');
//bringing user schema model
const User=require('../../models/User');
//testing this api
router.get('/demo', (req, res) => res.json({ msg: 'Profile Works' }));
//get request
//now need to check for the user who is trying to login
router.get('/',passport.authenticate('jwt', { session: false }),(req, res) => {
//initializing this as empty because need to add error msg
const errors = {};
//fetch current user profile and finding from profile model
//findone is a mongoose method which will find a specifc{single} thing
Profile.findOne({ user: req.user.id }) .populate('user', ['name']).then(profile => {
//if not found display error msg
if (!profile) {
errors.noprofile = 'no profile exists for this person';
return res.status(404).json(errors);
}
//if found then show proifle
res.json(profile);
})
.catch(err => res.status(404).json(err));
}
)
//to see all profiles at api/userprofile/all
router.get('/all',(req,res)=>{
Profile.find()
.populate('user',['name'])
.then(profiles=>{
if(!profiles){
errors.noprofile='no profiles';
return res.status(404).json(errors);
}
res.json(profiles);
})
.catch(err=>res.status(404).json({profile:'no profiles'}));
})
//getting profile by name
router.get('/profilename/:profilename',(req,res)=>{
Profile.findOne({profiename:req.params.profiename})
.populate('user',['name'])
.then(profile=>{
if(!profile){
errors.noprofile='there is no profile';
res.status(400).json(errors);
}
res.json(profile);
})
.catch(err=>res.status(404).json(err));
})
//getting profile by id
router.get('/users/:users_id',(req,res)=>{
Profile.findOne({profiename:req.params.profiename})
.populate('user',['name'])
.then(profile=>{
if(!profile){
errors.noprofile='there is no profile';
res.status(400).json(errors);
}
res.json(profile);
})
.catch(err=>res.status(404).json(err));
})
//post request
router.post(
'/',
passport.authenticate('jwt', { session: false }),
(req, res) => {
const {errors,isValid}=validateProfileInput(req.body);
//check validation
if(!isValid){
return res.status(400).json(errors);
}
//getting fields and adding in an obj
const fields={};
fields.user=req.user.id;
//checking if its sent from handle
if(req.body.profilename)fields.profilename=req.body.profilename;
if(req.body.company)fields.company=req.body.company;
if(req.body.location)fields.location=req.body.location;
//so splitting skills into an array when seperated by ','
if(typeof req.body.skills!=='undefined')
fields.skills=req.body.skills.split(',');
//searching by id and if profile has then update
Profile.findOne({user:req.user.id}).then(profile=>{
if(profile){
Profile.findOneAndUpdate({user:req.user.id},{$set:fields},{new:true})
.then(profile=>res.json(profile));
}
else{
//checking if there
Profile.findOne({profiename:fields.profilename}).then(profile=>{
if(profile){
errors.profiename='profile already there'
res.status(400).json(errors);
}
//saving and making new if not
new Profile(fields).save().then(profile=>res.json(profile));
})
}
})
}
);
//post req to add exp
router.post(
'/experience',
passport.authenticate('jwt', { session: false }),
(req, res) => {
const { errors, isValid } = validateExperienceInput(req.body);
// Check Validation
if (!isValid) {
// Return any errors with 400 status
return res.status(400).json(errors);
}
//to add new experience
Profile.findOne({ user: req.user.id }).then(profile => {
const newExperience = {
title: req.body.title,
company: req.body.company,
location: req.body.location,
from: req.body.from,
to: req.body.to,
description: req.body.description
};
// Add to exp array
profile.experience.unshift(newExperience);
profile.save().then(profile => res.json(profile));
});
}
);
//after adding if user wants to delete the experience
router.delete(
'/experience/:exp_id',
passport.authenticate('jwt', { session: false }),
(req, res) => {
const { errors, isValid } = validateExperienceInput(req.body);
// Check Validation
if (!isValid) {
// Return any errors with 400 status
return res.status(400).json(errors);
}
Profile.findOne({ user: req.user.id }).then(profile => {
const remove=profile.experience
.map(item=>item.id)
.indexof(req.params.exp_id);
//splicing out of array at index 1
profile.experience.splice(remove,1)
//saving
profile.save().then(profile=>res.json(profile));
})
.catch(err=>res.status(404).json(err));
}
);
module.exports = router;
Это код реагирования переднего плана:
import React, { Component } from 'react'
import { connect } from 'react-redux';
import PropTypes from 'prop-types';
import TextField from '../common/TextField';
import {withRouter} from 'react-router-dom';
import TextAreaField from '../common/TextAreaField';
import SelectListGroup from '../common/SelectListGroup';
import {createProfile} from '../../actions/userprofileAction';
class CreateProfile extends Component {
constructor(props){
super(props);
this.state={
profilename:'',
location:'',
skills:'',
interest:'',
bio:'',
errors:{}
}
this.onChange=this.onChange.bind(this);
this.onSubmit=this.onSubmit.bind(this);
}
componentWillReceiveProps(nextProps) {
if (nextProps.errors) {
this.setState({ errors: nextProps.errors });
}
}
onSubmit(e) {
e.preventDefault();
const profileData={
profilename:this.state.profilename,
location:this.state.location,
skills:this.state.skills,
interest:this.state.interest,
bio:this.state.bio
}
this.props.createProfile(profileData, this.props.history);
}
onChange(e) {
this.setState({ [e.target.name]: e.target.value });
}
render() {
const {errors}=this.state;
return (
<div className='createprofile'>
<div className='container'>
<div className="row">
<div className="col-md-8 m-auto">
<h1 className="display-4 text-center">Create Your Profile</h1>
<form onSubmit={this.onSubmit}>
<TextField
placeholder="Profile name"
name="profilename"
value={this.state.profilename}
onChange={this.onChange}
error={errors.profilename}
info="Enter the Profilename you want to keep"/>
<TextField
placeholder="Location"
name="location"
value={this.state.location}
onChange={this.onChange}
error={errors.location}
info="City (eg. Hamilton)"/>
<TextField
placeholder="Skills"
name="skills"
value={this.state.skills}
onChange={this.onChange}
error={errors.skills}
info="Enter the skills seperated by Commas (eg. HTML,Management, Marketing, Customer Service)"/>
<TextField
placeholder="Interests"
name="interest"
value={this.state.interest}
onChange={this.onChange}
error={errors.interest}
info="What are your interests? (eg. Blogging, Football, Cooking)"/>
<TextAreaField
placeholder="Bio"
name="bio"
value={this.state.bio}
onChange={this.onChange}
error={errors.bio}
info="Introduce yourself briefly"/>
<input
type="submit"
value="Create my PROFILE"
className="btn btn-info btn-block mt-4"
/>
</form>
</div>
</div>
</div>
</div>
)
}
}
CreateProfile.propTypes={
profile:PropTypes.object.isRequired,
errors:PropTypes.object.isRequired
}
const mapStateToProps = state => ({
profile: state.profile,
errors: state.errors
})
export default connect(mapStateToProps, { createProfile })(withRouter(CreateProfile));
userprofileAction.js:
import axios from 'axios';
import {GET_USERPROFILE,PROFILE_LOADING,GET_ERRORS,CLEAR_CURRENT_PROFILE} from './types';
//getting current profile
export const getProfile=()=>dispatch=>{
//dispatching loading state before req
dispatch(profileLoading());
axios.get('/api/userprofile')
.then(res=>
dispatch({
type:GET_USERPROFILE,
payload:res.data
}))
.catch(err=>
dispatch({
type:GET_USERPROFILE,
payload:{}
}))
}
// Create Profile
export const createProfile = (profileData, history) => dispatch => {
axios
.post('/api/userprofile', profileData)
.then(res => history.push('/dashboard'))
.catch(err =>
dispatch({
type: GET_ERRORS,
payload: err.response.data
})
);
};
//loading the profile
export const profileLoading=()=>{
return{
type:PROFILE_LOADING
}
}
//clearing profile
export const clearcurrentprofile=()=>{
return{
type:CLEAR_CURRENT_PROFILE
}
}
types.js:
export const GET_ERRORS='GET_ERRORS';
export const SET_CURRENT_USER = 'SET_CURRENT_USER';
export const GET_USERPROFILE='GET_USERPROFILE';
export const PROFILE_LOADING = 'PROFILE_LOADING';
export const CLEAR_CURRENT_PROFILE='CLEAR_CURRENT_PROFILE';
export const NO_PROFILE_FOUND='NO_PROFILE_FOUND';
export const GET_PROFILES='GET_PROFILES';