AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Need help with 2 scripts.(ns scripts) (https://forums.alliedmods.net/showthread.php?t=10453)

XunTric 02-19-2005 17:21

Need help with 2 scripts.(ns scripts)
 
1. Ok im trying to make a simple respawn plugin. When you write amx_spawn "name" i want it to spawn the player, but it doesnt. Whats wrong? Just as you know im going to use this in ns. Can somebody help me? (It compiles, but not work...) Here it is:
Code:
#include <amxmodx> #include <amxmisc> public plugin_init() { register_plugin("Player Spawner", "1.0", "XunTric") register_concmd("amx_spawn", "spawn", ADMIN_KICK, "<name> Spawns a player from death") } public spawn(id,level,cid) {     if (!cmd_access(id,level,cid,2))          return PLUGIN_HANDLED     new arg[32]     read_argv(1,arg,31)     new player = cmd_target(id,arg,2)     if(!player)          return PLUGIN_HANDLED     new name[64];     get_user_name(player,name,63);     client_cmd(player, "spawn")         return PLUGIN_HANDLED }

2. Another small plugin for ns. What im trying to make is when amx_res "name" "resources to give" is used, that player will get resources (alien players only.) This one wont compile. Somebody have an idea of what i did wrong? Here it is:
Code:
#include <amxmodx> #include <amxmisc> #include <ns> public plugin_init() { register_plugin("Give Resources", "1.0", "XunTric") register_concmd("amx_res", "cmdres", ADMIN_KICK, "<name> <resources to give>") } public cmdres(id,level,cid) {     if (!cmd_access(id,level,cid,2))          return PLUGIN_HANDLED     new arg[32]     read_argv(1,arg,31)     new player = cmd_target(id,arg,2)     if(!player)          return PLUGIN_HANDLED     new name[64];     get_user_name(player,name,63);     ns_set_res(player, "%s")     client_print(player, print_chat, "The admin gave you %s resources")         return PLUGIN_HANDLED }

XxAvalanchexX 02-19-2005 19:56

For 1: typing spawn in console makes you spawn? Since when?

For 2: It's your usage of ns_set_res. Try this instead:

Code:
#include <amxmodx> #include <amxmisc> #include <ns> public plugin_init() { register_plugin("Give Resources", "1.0", "XunTric") register_concmd("amx_res", "cmdres", ADMIN_KICK, "<name> <resources to give>") } public cmdres(id,level,cid) {     if (!cmd_access(id,level,cid,3))          return PLUGIN_HANDLED     new arg1[32], arg2[32]     read_argv(1,arg1,31)     read_argv(2,arg2,31)     new player = cmd_target(id,arg1,2)     if(!player)          return PLUGIN_HANDLED     ns_set_res(player,ns_get_res(player) + str_to_num(arg2))     client_print(player, print_chat, "The admin gave you %i resources",str_to_num(arg2))     return PLUGIN_HANDLED }

XunTric 02-20-2005 05:32

Why did i know you would help? You know everything lol :D


It compiles without any errors or warnings :D ill test it now
-------------------------------------------------------------------
EDIT:
It works perfectly!

Can you help me make a new spawn script then? Or give me a link to a plugin like that. I searched for it but i only found a respawn forever plugin. what i want is to only respawn one guy...

XxAvalanchexX 02-20-2005 14:51

Code:
#include <amxmodx> #include <amxmisc> #include <fun> public plugin_init() {     register_plugin("Player Spawner", "1.0", "XunTric")     register_concmd("amx_spawn", "spawn", ADMIN_KICK, "<name> Spawns a player from death") } public spawn(id,level,cid) {     if (!cmd_access(id,level,cid,2))          return PLUGIN_HANDLED     new arg[32]     read_argv(1,arg,31)     new player = cmd_target(id,arg,2)     if(!player)          return PLUGIN_HANDLED     user_spawn(player);     set_task(0.5,"spawnagain",player);     return PLUGIN_HANDLED } public spawnagain(id) {     user_spawn(id); }

XunTric 02-20-2005 16:18

Thanks! Lol ill start sending private messages to you since you allways helps and know everything 8)
------------------------------------------
EDIT:
Damn ive allready made a thread on plugin forum and it wont compile at all. it comes a "internal error" or something. Help XxAvalanchexX??


All times are GMT -4. The time now is 14:09.

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