Forum

> > CS2D > Scripts > Creating bot spray script
Forums overviewCS2D overview Scripts overviewLog in to reply

English Creating bot spray script

1 reply
To the start Previous 1 Next To the start

old Creating bot spray script

qwertyu0
User Off Offline

Quote
Good morning, I am beginner in creating scripts. I wanted to "learn" bots some new things. I wanted to start with something easy, for example with learning them spraying. I have tried using adhook, function, ai_spray. I wanted them to spray when <50hp, while reloading, but I have got errors like "there should be ( or ' near if" but I haven't seen any ( near "if" in scrips I have read in order to learn how to make scrips on my own.

My scripts (there were other variations, but I place only "best"):

addhook("serveraction","bot.spray")
function bot.spray(id,"health")
     if (player(id,"health")<50 then
          player(id,"health")ai_spray
     end
end

Error: <name> "..." near "health" - something like that, I don't understand.

Other sample:

addhook("serveraction","bot.spray")
function bot.spray(id,"reload")
     if (player(id,"reload") then
          ai_spray
     end
end

similar error, but with reload.

Could someone write example of script that I have to create in order to make bots spray while reloading or having less than 50hp?
I have found on the forum that I need ai_spray, but how to use that?

I want to add only that I don't want links to ready scripts for bots, beacause I am not interested in resuts, but in how to achieve them.

I will be very gratefull for help. Also I am sorry for my English, but it is not my main language

old Re: Creating bot spray script

MikuAuahDark
User Off Offline

Quote
next time, use
1
[code][ /code]
from your code, it done wrong.

Fix:
1
2
3
4
5
6
7
if bot==nil then bot={} end
addhook("reload","bot.spray")
function bot.spray(id)
	if player(id,"bot")==true and player(id,"health")<50 then
		ai_spray(id)
	end
end

P.S: it's night in my country(indonesia)
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview