Raised This Month: $32 Target: $400
 8% 

change map in plugin script?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
suhdude
Senior Member
Join Date: Mar 2016
Location: Sweden
Old 11-12-2017 , 23:10   change map in plugin script?
Reply With Quote #1

I want people to be able to type /mapname in chat to change the level.
I have tried this:

engine_changelevel(de_dust2); //undefined symbol

change_level(de_dust2); //undefined symbol

console_cmd(0, "rcon changelevel de_dust2") //not working


client_cmd(0, "rcon changelevel de_dust2") //not working

console_cmd(0 "rcon amx_map de_dust2") //not working

etc etc..
I don't understand what I need to #include..

Also, is there a smart way of not having to do 50 different functions, one for every map?

Thanks

Last edited by suhdude; 11-12-2017 at 23:11.
suhdude is offline
aron9forever
Veteran Member
Join Date: Feb 2013
Location: Rromania
Old 11-13-2017 , 02:04   Re: change map in plugin script?
Reply With Quote #2

hook all chat messages by just registering the "say" command
check if first character is "/"
if it is, read the rest of the string
now format the string to add cstrike/maps/ to the beginning and .bsp to the end
check if file_exists (to see if the map is installed)
if it exists, change to it however you want (look for inspiration in admincmd from 1.8.3, older ones might have a privilege elevation vulnerability in them)
__________________
Meanwhile, in 2050:
Quote:
Originally Posted by aron9forever
useless small optimizations
Quote:
Originally Posted by Black Rose View Post
On a map that is 512x512x128 units you end up with 3,355,443,200,000 different "positions". To store each one of those positions individually in the variable "user_or" you need 12 terabytes of memory.
aron9forever is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 11-13-2017 , 07:51   Re: change map in plugin script?
Reply With Quote #3

Quote:
engine_changelevel(de_dust2); //undefined symbol

change_level(de_dust2); //undefined symbol
Put the mapname in quotes.

Quote:
client_cmd(0, "rcon changelevel de_dust2") //not working
You force all users to use the command?!

Quote:
console_cmd(0 "rcon amx_map de_dust2") //not working
Totally wrong usage + why do you use rcon when you're already executing it from the server console?

All it takes is a little logic and consulting the API.
__________________

Last edited by OciXCrom; 11-13-2017 at 09:55.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-13-2017 , 09:30   Re: change map in plugin script?
Reply With Quote #4

@suhdude, you need to learn to search for these types of things. It's the most important part of learning how to script/program. If there is something you want to do that you know has been done in a plugin, find that plugin and look at its code. As you stated in your post, you know that amx_map changes the map so simply look at the code for amx_map.

Quote:
Originally Posted by OciXCrom View Post
Put the mapname in brackets.
What?? Brackets, [], won't do anything.
__________________

Last edited by fysiks; 11-13-2017 at 09:35.
fysiks is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 11-13-2017 , 09:56   Re: change map in plugin script?
Reply With Quote #5

quotes*
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
suhdude
Senior Member
Join Date: Mar 2016
Location: Sweden
Old 11-13-2017 , 10:20   Re: change map in plugin script?
Reply With Quote #6

Quote:
Originally Posted by fysiks View Post
@suhdude, you need to learn to search for these types of things. It's the most important part of learning how to script/program. If there is something you want to do that you know has been done in a plugin, find that plugin and look at its code. As you stated in your post, you know that amx_map changes the map so simply look at the code for amx_map.



What?? Brackets, [], won't do anything.
Thank you for responding.

I have searched in the API and found change_level, it did not work and then I found that its been updated to engine_changelevel. I tried include every module I could think of but the function was still not recognized.
Then I starting looking trough map change .smas like some of the ones that come with amx and others on this website. I did not find what I was looking for.

Then I tried cmd functions in 20 different ways, with brackets, without, sending to all clients, sending to one..

I know I post too much and I'm sorry, its just been so much fun learning to put things together.
I know its not the best way to learn, but its the only way for me to stay motivated doing this, taking parts and focusing on my little projects.

And I think I ask some valid questions, and I do spend time testing things out and I do search a lot most of the time, but maybe I need the basics to understand simple as that.
I do search trough tutorials, but most of the things I try to do seem to be part of "intermediate to advanced". And when I did the Intro to amx tutorial, 80% of it was just someone elses if/else code.
I have learned so much more asking, and getting help. I admit I have used this subforum too much, but I have some threads where many people tried to help me and failed, and then I figure it out for myself.

Last edited by suhdude; 11-13-2017 at 10:33.
suhdude is offline
suhdude
Senior Member
Join Date: Mar 2016
Location: Sweden
Old 11-13-2017 , 10:24   Re: change map in plugin script?
Reply With Quote #7

Quote:
Originally Posted by OciXCrom View Post
Put the mapname in quotes.



You force all users to use the command?!



Totally wrong usage + why do you use rcon when you're already executing it from the server console?

All it takes is a little logic and consulting the API.
engine_changelevel("de_aztec_go"); //Still not recognized

I tried rcon after just trying:
console_cmd(0 "amx_map de_dust2")
and
console_cmd(0 "changelevel de_dust2")

I have tried looking at the API, I guess I can't think logically.
suhdude is offline
suhdude
Senior Member
Join Date: Mar 2016
Location: Sweden
Old 11-13-2017 , 10:40   Re: change map in plugin script?
Reply With Quote #8

Quote:
Originally Posted by aron9forever View Post
hook all chat messages by just registering the "say" command
check if first character is "/"
if it is, read the rest of the string
now format the string to add cstrike/maps/ to the beginning and .bsp to the end
check if file_exists (to see if the map is installed)
if it exists, change to it however you want (look for inspiration in admincmd from 1.8.3, older ones might have a privilege elevation vulnerability in them)
Hmm, I'm a little confused here.

1. I have already put: register_clcmd("say /rt_nuke", "de_nuke") // and tried different functions. You want me to just register register_clcmd("say", "de_nuke")?
2. When I test it with "say", I have checked that / is the first thing i put before mapname. What first character do you want me to look for?
3. Do you want me to do: engine_changelevel("/cstrike/maps/de_aztec_go"); ? Or is this post made to help me not have to do multiple functions?
4. Map definetly exists in cstrike/maps, and is added to amx maps.ini

Thank you for being patient me.

Last edited by suhdude; 11-13-2017 at 10:44.
suhdude is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 11-13-2017 , 11:31   Re: change map in plugin script?
Reply With Quote #9

You would go obviously for server_cmd function. If you don't have basic knowledge of amxx scripting you could just start a thread in "Suggestions / Requests" section.
Btw, I believe there are bunch of such plugins. Just try to search.

P.S. If you want to echo the map changing process, you can just use admin slash plugin and change map by using short command in chat /map "map_name"

Last edited by siriusmd99; 11-13-2017 at 11:36.
siriusmd99 is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 11-13-2017 , 12:24   Re: change map in plugin script?
Reply With Quote #10

Quote:
Originally Posted by suhdude View Post
engine_changelevel("de_aztec_go"); //Still not recognized

I have tried looking at the API, I guess I can't think logically.
If you looked ad the API, you should have noticed that the function (if the name itself wasn't clear enough) belongs in the engine module, so add #include <engine>.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
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 23:52.


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