AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Random spawn points? (https://forums.alliedmods.net/showthread.php?t=22723)

Kensai 01-02-2006 17:17

Random spawn points?
 
Is there an easy way to make this plugin, spawn players randomly instead of just at main spawns?

Code:
/* AMXX Mod script. * * (c) Copyright 2004, developed by Geesu modified by v3x * This file is provided as is (no warranties). * * Changelog * 1.0: *   Pistols are now given to players when they respawn *   sv_checkpistols cvar added, if this is set to 0, then players will always spawn with a pistol, otherwise they will only spawn with a pistol when it is not scoutzknivez and not a ka map *   sv_respawn cvar added, set this to 0 to disable the plugin */ #include <amxmodx> #include <fun> #include <cstrike> #define DISABLE_CS 0 // team ids #define UNASSIGNED 0 #define TS 1 #define CTS 2 #define AUTO_TEAM 5 #define CVAR_CT_TIME    "sv_respawn_time_ct" #define CVAR_TE_TIME    "sv_respawn_time_te" new bool:g_PistolsDisabled = false public plugin_init(){     register_plugin("Respawn Forever","1.1","Pimp Daddy (OoTOAoO)")     register_event("DeathMsg","on_Death","a")         register_cvar("sv_checkpistols","1")     register_cvar("sv_respawn","1")     register_cvar(CVAR_CT_TIME,"2")     register_cvar(CVAR_TE_TIME,"3")     register_clcmd("say /spawn","ClCmd_Respawn") } public ClCmd_Respawn(id) {     new CsTeams:iTeam = cs_get_user_team(id);         if((iTeam == CS_TEAM_CT || iTeam == CS_TEAM_T) && !is_user_alive(id))     {         new parm[1];         parm[0] = id;         switch(iTeam)         {             case CS_TEAM_CT:             {                 set_task(get_cvar_float(CVAR_CT_TIME) + 0.5,"player_spawn",72,parm,1)                 set_task(get_cvar_float(CVAR_CT_TIME) + 0.7,"player_spawn",72,parm,1)                 set_task(get_cvar_float(CVAR_CT_TIME) + 0.9,"player_giveitems",72,parm,1)             }             case CS_TEAM_T:             {                 set_task(get_cvar_float(CVAR_TE_TIME) + 0.5,"player_spawn",72,parm,1)                 set_task(get_cvar_float(CVAR_TE_TIME) + 0.7,"player_spawn",72,parm,1)                 set_task(get_cvar_float(CVAR_TE_TIME) + 0.9,"player_giveitems",72,parm,1)             }         }     }     return PLUGIN_CONTINUE; } public check_pistols() {         /* Determine if we should give players a pistol or not */     if ( get_cvar_num("sv_checkpistols") )     {         set_task(1.0, "check_pistols")         new mapname[32]         get_mapname(mapname,31)         if ( containi(mapname,"ka_")!=-1 || containi(mapname,"scoutzknivez")!=-1 )                 g_PistolsDisabled = true     } } public on_Death() {     if ( !get_cvar_num("sv_respawn") )         return PLUGIN_CONTINUE         new victim_id = read_data(2)     new parm[1]     parm[0]=victim_id         /* Spawn the player twice to avoid the HL engine bug */     switch(get_user_team(victim_id))     {         case CTS:         {             set_task(get_cvar_float(CVAR_CT_TIME) + 0.5,"player_spawn",72,parm,1)             set_task(get_cvar_float(CVAR_CT_TIME) + 0.7,"player_spawn",72,parm,1)             set_task(get_cvar_float(CVAR_CT_TIME) + 0.9,"player_giveitems",72,parm,1)         }         case TS:         {             set_task(get_cvar_float(CVAR_TE_TIME) + 0.5,"player_spawn",72,parm,1)             set_task(get_cvar_float(CVAR_TE_TIME) + 0.7,"player_spawn",72,parm,1)             set_task(get_cvar_float(CVAR_TE_TIME) + 0.9,"player_giveitems",72,parm,1)         }     }     return PLUGIN_CONTINUE } public player_giveitems(parm[1]) {     new id = parm[0]     give_item(id, "item_suit")     give_item(id, "weapon_knife")     /* Determines if a players should be given a pistol */     if ( !g_PistolsDisabled )     {         new wpnList[32] = 0, number = 0, bool:foundGlock = false, bool:foundUSP = false         get_user_weapons(id,wpnList,number)                 /* Determine if the player already has a pistol */         for (new i = 0;i < number;i++)         {             if (wpnList[i] == CSW_GLOCK18)                 foundGlock = true             if (wpnList[i] == CSW_USP)                 foundUSP = true         }                 /* Give a T his/her pistol */         if ( get_user_team(id)==TS && !foundGlock )         {                 give_item(id,"weapon_glock18")                 give_item(id,"ammo_9mm")                 give_item(id,"ammo_9mm")         }         /* Give a CT his/her pistol */         else if ( get_user_team(id)==CTS && !foundUSP )         {                 give_item(id,"weapon_usp")                 give_item(id,"ammo_45acp")                 give_item(id,"ammo_45acp")         }     }     return PLUGIN_CONTINUE } public player_spawn(parm[1])     spawn(parm[0])

Kensai 01-02-2006 20:24

Bump.

I'm just looking how to make a few extra spawn points each map, nothing too fancy just a little bit away form spawns.

teame06 01-02-2006 20:27

No, You have to have a set of predefined spawn points. You can look at tdm or csdm on how they do it. What they do is have read a config file with a set of origin and another set of view angle. When a player is spawned they use set_user_origin to move them.

Kensai 01-02-2006 20:31

Alright thanks, I'll try to understand that lol.


All times are GMT -4. The time now is 15:48.

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