Posts: 43
Threads: 1
Joined: Dec 2012
Reputation:
0
Thanks, I understood as to increase damage at the weapon (I made strengthened deagle), but for me still remain unclear how to make it:
(01-20-2013, 10:42)ltybcs Wrote: How to make so that on each card there was a different weapon, on outpost for example rsass, on seatown for example usp.45 and so on, and whether it is possible to make that I had a weapon not such as at all, when at all usp.45 at me for example p90?
Please, you can explain in more detail
Posts: 285
Threads: 15
Joined: Nov 2011
Reputation:
12
(01-20-2013, 10:42)ltybcs Wrote: I had a weapon not such as at all,when at all usp.45 at me for example p90? Can't understand what you mean there as for your other questions first I use the onPlayerSpawned event which is fired every time a player spawns.Next I create a timer because ,for me at least ,assigning weapons at spawn doesn't work.Then I check for the map using GetDvar("mapname") and if it equals mp_dome I proceed to see the team.Next I get the weapon ID because PrimaryWeapon takes int not string then I assign the weapon ID to primary and current weapon as for zombies ,I also change ammo to make sure they don't have any ammo
Posts: 520
Threads: 29
Joined: Nov 2012
Reputation:
11
01-20-2013, 13:35
(This post was last modified: 01-20-2013, 13:35 by 99IRock.)
I guess he means this.
Use onplayerspawned
base.OnPlayerSpawned(Client);
}
Code: public override void OnPlayerSpawned(ServerClient Client)
{
Than this for what map
Code: string map = GetDvar("mapname");
if (map == "mp_dome") // This is for map dome
{
int iWeaponID = GetWeapon("iw5_aa12_mp_grip_xmags_camo08");
Client.Other.PrimaryWeapon = iWeaponID; // Sets primary weapon to iWeaponID (aa12)
Client.Ammo.PrimaryAmmoClip = +50; //Gives the clip of primary weapon +50
Client.Ammo.PrimaryAmmo = +2000; // Gives 2000 ammo (If you reload you take ammo from this 2000)
}
if (Client.XUID == "YourXUID") // Put in your xuid there , so you get the ump45 instead of the aa12
{
int iWeaponID = GetWeapon("iw5_ump45_mp_silencer_xmags_rof_camo08");
Client.Other.PrimaryWeapon = iWeaponID;
Client.Ammo.PrimaryAmmoClip = +400;
Client.Ammo.PrimaryAmmo = +400;
}
}
I guess this is what you need?
Posts: 43
Threads: 1
Joined: Dec 2012
Reputation:
0
01-20-2013, 13:41
(This post was last modified: 01-20-2013, 13:51 by ltybcs.)
Yes, that I looked for this that, many thanks archit and 99IRock for the help
Posts: 285
Threads: 15
Joined: Nov 2011
Reputation:
12
Rock did you test the functions?
Posts: 43
Threads: 1
Joined: Dec 2012
Reputation:
0
Yes, the code works but I have with it a small problem. At me in a code which below under a spoiler when I come into the game Deagle it is added by the 3rd weapon instead of replaces the basic.
How to replace the main weapon with Deagle and that it wasn't the 3rd weapon?
Code: using System;
using System.Collections.Generic;
using System.Text;
using System.Timers;
using Addon;
namespace edit
{
public class Class1 : CPlugin
{
public override void OnPlayerSpawned(ServerClient Client)
{
string map = GetDvar("mapname");
if (map == "mp_dome")
if (Client.XUID == "0110000105987c4c")
{
if (Client.Team == Teams.Allies)
{
int weapon = GetWeapon("iw5_deserteagle_mp");
Client.Other.PrimaryWeapon = weapon;
Client.Ammo.PrimaryAmmoClip = +400;
Client.Ammo.PrimaryAmmo = +400;
}
else
{
int weapon = GetWeapon("iw5_usp.45_mp", Attachments.tactical, Attachments.none, Attachments.none, Camos.Choco, Reticles.None);
Client.Other.PrimaryWeapon = weapon;
Client.Other.CurrentWeapon = weapon;
Client.Ammo.PrimaryAmmo = 0;
Client.Ammo.PrimaryAmmoClip = 0;
}
}
if (map == "mp_alpha")
if (Client.XUID == "0110000105987c4c")
{
if (Client.Team == Teams.Allies)
{
int weapon = GetWeapon("iw5_deserteagle_mp");
Client.Other.PrimaryWeapon = weapon;
Client.Ammo.PrimaryAmmoClip = +400;
Client.Ammo.PrimaryAmmo = +400;
}
else
{
int weapon = GetWeapon("iw5_usp.45_mp", Attachments.tactical, Attachments.none, Attachments.none, Camos.Choco, Reticles.None);
Client.Other.PrimaryWeapon = weapon;
Client.Other.CurrentWeapon = weapon;
Client.Ammo.PrimaryAmmo = 0;
Client.Ammo.PrimaryAmmoClip = 0;
}
}
if (map == "mp_bootleg")
if (Client.XUID == "0110000105987c4c")
{
if (Client.Team == Teams.Allies)
{
int weapon = GetWeapon("iw5_deserteagle_mp");
Client.Other.PrimaryWeapon = weapon;
Client.Ammo.PrimaryAmmoClip = +400;
Client.Ammo.PrimaryAmmo = +400;
}
else
{
int weapon = GetWeapon("iw5_usp.45_mp", Attachments.tactical, Attachments.none, Attachments.none, Camos.Choco, Reticles.None);
Client.Other.PrimaryWeapon = weapon;
Client.Other.CurrentWeapon = weapon;
Client.Ammo.PrimaryAmmo = 0;
Client.Ammo.PrimaryAmmoClip = 0;
}
}
if (map == "mp_bravo")
if (Client.XUID == "0110000105987c4c")
{
if (Client.Team == Teams.Allies)
{
int weapon = GetWeapon("iw5_deserteagle_mp");
Client.Other.PrimaryWeapon = weapon;
Client.Ammo.PrimaryAmmoClip = +400;
Client.Ammo.PrimaryAmmo = +400;
}
else
{
int weapon = GetWeapon("iw5_usp.45_mp", Attachments.tactical, Attachments.none, Attachments.none, Camos.Choco, Reticles.None);
Client.Other.PrimaryWeapon = weapon;
Client.Other.CurrentWeapon = weapon;
Client.Ammo.PrimaryAmmo = 0;
Client.Ammo.PrimaryAmmoClip = 0;
}
}
if (map == "mp_carbon")
if (Client.XUID == "0110000105987c4c")
{
if (Client.Team == Teams.Allies)
{
int weapon = GetWeapon("iw5_deserteagle_mp");
Client.Other.PrimaryWeapon = weapon;
Client.Ammo.PrimaryAmmoClip = +400;
Client.Ammo.PrimaryAmmo = +400;
}
else
{
int weapon = GetWeapon("iw5_usp.45_mp", Attachments.tactical, Attachments.none, Attachments.none, Camos.Choco, Reticles.None);
Client.Other.PrimaryWeapon = weapon;
Client.Other.CurrentWeapon = weapon;
Client.Ammo.PrimaryAmmo = 0;
Client.Ammo.PrimaryAmmoClip = 0;
}
}
if (map == "mp_exchange")
if (Client.XUID == "0110000105987c4c")
{
if (Client.Team == Teams.Allies)
{
int weapon = GetWeapon("iw5_deserteagle_mp");
Client.Other.PrimaryWeapon = weapon;
Client.Ammo.PrimaryAmmoClip = +400;
Client.Ammo.PrimaryAmmo = +400;
}
else
{
int weapon = GetWeapon("iw5_usp.45_mp", Attachments.tactical, Attachments.none, Attachments.none, Camos.Choco, Reticles.None);
Client.Other.PrimaryWeapon = weapon;
Client.Other.CurrentWeapon = weapon;
Client.Ammo.PrimaryAmmo = 0;
Client.Ammo.PrimaryAmmoClip = 0;
}
}
if (map == "mp_hardhat")
if (Client.XUID == "0110000105987c4c")
{
if (Client.Team == Teams.Allies)
{
int weapon = GetWeapon("iw5_deserteagle_mp");
Client.Other.PrimaryWeapon = weapon;
Client.Ammo.PrimaryAmmoClip = +400;
Client.Ammo.PrimaryAmmo = +400;
}
else
{
int weapon = GetWeapon("iw5_usp.45_mp", Attachments.tactical, Attachments.none, Attachments.none, Camos.Choco, Reticles.None);
Client.Other.PrimaryWeapon = weapon;
Client.Other.CurrentWeapon = weapon;
Client.Ammo.PrimaryAmmo = 0;
Client.Ammo.PrimaryAmmoClip = 0;
}
}
if (map == "mp_interchange")
if (Client.XUID == "0110000105987c4c")
{
if (Client.Team == Teams.Allies)
{
int weapon = GetWeapon("iw5_deserteagle_mp");
Client.Other.PrimaryWeapon = weapon;
Client.Ammo.PrimaryAmmoClip = +400;
Client.Ammo.PrimaryAmmo = +400;
}
else
{
int weapon = GetWeapon("iw5_usp.45_mp", Attachments.tactical, Attachments.none, Attachments.none, Camos.Choco, Reticles.None);
Client.Other.PrimaryWeapon = weapon;
Client.Other.CurrentWeapon = weapon;
Client.Ammo.PrimaryAmmo = 0;
Client.Ammo.PrimaryAmmoClip = 0;
}
}
if (map == "mp_lambeth")
if (Client.XUID == "0110000105987c4c")
{
if (Client.Team == Teams.Allies)
{
int weapon = GetWeapon("iw5_deserteagle_mp");
Client.Other.PrimaryWeapon = weapon;
Client.Ammo.PrimaryAmmoClip = +400;
Client.Ammo.PrimaryAmmo = +400;
}
else
{
int weapon = GetWeapon("iw5_usp.45_mp", Attachments.tactical, Attachments.none, Attachments.none, Camos.Choco, Reticles.None);
Client.Other.PrimaryWeapon = weapon;
Client.Other.CurrentWeapon = weapon;
Client.Ammo.PrimaryAmmo = 0;
Client.Ammo.PrimaryAmmoClip = 0;
}
}
if (map == "mp_mogadishu")
if (Client.XUID == "0110000105987c4c")
{
if (Client.Team == Teams.Allies)
{
int weapon = GetWeapon("iw5_deserteagle_mp");
Client.Other.PrimaryWeapon = weapon;
Client.Ammo.PrimaryAmmoClip = +400;
Client.Ammo.PrimaryAmmo = +400;
}
else
{
int weapon = GetWeapon("iw5_usp.45_mp", Attachments.tactical, Attachments.none, Attachments.none, Camos.Choco, Reticles.None);
Client.Other.PrimaryWeapon = weapon;
Client.Other.CurrentWeapon = weapon;
Client.Ammo.PrimaryAmmo = 0;
Client.Ammo.PrimaryAmmoClip = 0;
}
}
if (map == "mp_paris")
if (Client.XUID == "0110000105987c4c")
{
if (Client.Team == Teams.Allies)
{
int weapon = GetWeapon("iw5_deserteagle_mp");
Client.Other.PrimaryWeapon = weapon;
Client.Ammo.PrimaryAmmoClip = +400;
Client.Ammo.PrimaryAmmo = +400;
}
else
{
int weapon = GetWeapon("iw5_usp.45_mp", Attachments.tactical, Attachments.none, Attachments.none, Camos.Choco, Reticles.None);
Client.Other.PrimaryWeapon = weapon;
Client.Other.CurrentWeapon = weapon;
Client.Ammo.PrimaryAmmo = 0;
Client.Ammo.PrimaryAmmoClip = 0;
}
}
if (map == "mp_plaza2")
if (Client.XUID == "0110000105987c4c")
{
if (Client.Team == Teams.Allies)
{
int weapon = GetWeapon("iw5_deserteagle_mp");
Client.Other.PrimaryWeapon = weapon;
Client.Ammo.PrimaryAmmoClip = +400;
Client.Ammo.PrimaryAmmo = +400;
}
else
{
int weapon = GetWeapon("iw5_usp.45_mp", Attachments.tactical, Attachments.none, Attachments.none, Camos.Choco, Reticles.None);
Client.Other.PrimaryWeapon = weapon;
Client.Other.CurrentWeapon = weapon;
Client.Ammo.PrimaryAmmo = 0;
Client.Ammo.PrimaryAmmoClip = 0;
}
}
if (map == "mp_radar")
if (Client.XUID == "0110000105987c4c")
{
if (Client.Team == Teams.Allies)
{
int weapon = GetWeapon("iw5_deserteagle_mp");
Client.Other.PrimaryWeapon = weapon;
Client.Ammo.PrimaryAmmoClip = +400;
Client.Ammo.PrimaryAmmo = +400;
}
else
{
int weapon = GetWeapon("iw5_usp.45_mp", Attachments.tactical, Attachments.none, Attachments.none, Camos.Choco, Reticles.None);
Client.Other.PrimaryWeapon = weapon;
Client.Other.CurrentWeapon = weapon;
Client.Ammo.PrimaryAmmo = 0;
Client.Ammo.PrimaryAmmoClip = 0;
}
}
if (map == "mp_seatown")
if (Client.XUID == "0110000105987c4c")
{
if (Client.Team == Teams.Allies)
{
int weapon = GetWeapon("iw5_deserteagle_mp");
Client.Other.PrimaryWeapon = weapon;
Client.Ammo.PrimaryAmmoClip = +400;
Client.Ammo.PrimaryAmmo = +400;
}
else
{
int weapon = GetWeapon("iw5_usp.45_mp", Attachments.tactical, Attachments.none, Attachments.none, Camos.Choco, Reticles.None);
Client.Other.PrimaryWeapon = weapon;
Client.Other.CurrentWeapon = weapon;
Client.Ammo.PrimaryAmmo = 0;
Client.Ammo.PrimaryAmmoClip = 0;
}
}
if (map == "mp_underground")
if (Client.XUID == "0110000105987c4c")
{
if (Client.Team == Teams.Allies)
{
int weapon = GetWeapon("iw5_deserteagle_mp");
Client.Other.PrimaryWeapon = weapon;
Client.Ammo.PrimaryAmmoClip = +400;
Client.Ammo.PrimaryAmmo = +400;
}
else
{
int weapon = GetWeapon("iw5_usp.45_mp", Attachments.tactical, Attachments.none, Attachments.none, Camos.Choco, Reticles.None);
Client.Other.PrimaryWeapon = weapon;
Client.Other.CurrentWeapon = weapon;
Client.Ammo.PrimaryAmmo = 0;
Client.Ammo.PrimaryAmmoClip = 0;
}
}
if (map == "mp_village")
if (Client.XUID == "0110000105987c4c")
{
if (Client.Team == Teams.Allies)
{
int weapon = GetWeapon("iw5_deserteagle_mp");
Client.Other.PrimaryWeapon = weapon;
Client.Ammo.PrimaryAmmoClip = +400;
Client.Ammo.PrimaryAmmo = +400;
}
else
{
int weapon = GetWeapon("iw5_usp.45_mp", Attachments.tactical, Attachments.none, Attachments.none, Camos.Choco, Reticles.None);
Client.Other.PrimaryWeapon = weapon;
Client.Other.CurrentWeapon = weapon;
Client.Ammo.PrimaryAmmo = 0;
Client.Ammo.PrimaryAmmoClip = 0;
}
}
if (map == "mp_terminal_cls")
if (Client.XUID == "0110000105987c4c")
{
if (Client.Team == Teams.Allies)
{
int weapon = GetWeapon("iw5_deserteagle_mp");
Client.Other.PrimaryWeapon = weapon;
Client.Ammo.PrimaryAmmoClip = +400;
Client.Ammo.PrimaryAmmo = +400;
}
else
{
int weapon = GetWeapon("iw5_usp.45_mp", Attachments.tactical, Attachments.none, Attachments.none, Camos.Choco, Reticles.None);
Client.Other.PrimaryWeapon = weapon;
Client.Other.CurrentWeapon = weapon;
Client.Ammo.PrimaryAmmo = 0;
Client.Ammo.PrimaryAmmoClip = 0;
}
}
if (map == "mp_aground_ss")
if (Client.XUID == "0110000105987c4c")
{
if (Client.Team == Teams.Allies)
{
int weapon = GetWeapon("iw5_deserteagle_mp");
Client.Other.PrimaryWeapon = weapon;
Client.Ammo.PrimaryAmmoClip = +400;
Client.Ammo.PrimaryAmmo = +400;
}
else
{
int weapon = GetWeapon("iw5_usp.45_mp", Attachments.tactical, Attachments.none, Attachments.none, Camos.Choco, Reticles.None);
Client.Other.PrimaryWeapon = weapon;
Client.Other.CurrentWeapon = weapon;
Client.Ammo.PrimaryAmmo = 0;
Client.Ammo.PrimaryAmmoClip = 0;
}
}
if (map == "mp_aqueduct_ss")
if (Client.XUID == "0110000105987c4c")
{
if (Client.Team == Teams.Allies)
{
int weapon = GetWeapon("iw5_deserteagle_mp");
Client.Other.PrimaryWeapon = weapon;
Client.Ammo.PrimaryAmmoClip = +400;
Client.Ammo.PrimaryAmmo = +400;
}
else
{
int weapon = GetWeapon("iw5_usp.45_mp", Attachments.tactical, Attachments.none, Attachments.none, Camos.Choco, Reticles.None);
Client.Other.PrimaryWeapon = weapon;
Client.Other.CurrentWeapon = weapon;
Client.Ammo.PrimaryAmmo = 0;
Client.Ammo.PrimaryAmmoClip = 0;
}
}
}
}
}
Posts: 43
Threads: 1
Joined: Dec 2012
Reputation:
0
Nobody can help me?
Posts: 520
Threads: 29
Joined: Nov 2012
Reputation:
11
01-23-2013, 14:52
(This post was last modified: 01-23-2013, 14:53 by 99IRock.)
Using onsay can fix it, I don't know why it does this on spawn..
If you use onsay and than a message like !deagle, and then let it spawn deagle it will work fine
You can also try to do this :
Client.Other.CurrentWeapon = weapon;
I don't know if it will work.
(and if currentweapon is spelled correctly (The high letters C and W))
Posts: 273
Threads: 14
Joined: Aug 2012
Reputation:
17
01-23-2013, 15:47
(This post was last modified: 01-23-2013, 15:58 by 8q4s8.)
currentweapon doesn't work with OnPlayerSpawned, you have to use a timer and then give the weapon to the player 1 or 2 seconds after spawn.
I found this code somewhere on itsmods, I think that should work too
CSHARP Code
using System; using System.Collections.Generic; using System.Text; using Addon; namespace ClassLibrary1 { public class Class1:CPlugin { Dictionary <int, int> ProcessSpawn = new Dictionary <int, int>(); public override void OnPlayerSpawned(ServerClient Client) { ProcessSpawn.Add(Client.ClientNum, 1/*seconds*/ * 1000 / AddonFrameInterval); } public override void OnAddonFrame() { List <int> PSKeys = new List <int>(ProcessSpawn. Keys); foreach (int key in PSKeys) { ProcessSpawn[key]--; if (ProcessSpawn[key] == 0) { ServerClient Client = GetClient(key); if (Client.Team == Teams.Allies) { if (Client.XUID == "xxxxxxxxxxxxxxxx") { int weap = GetWeapon("iw5_acr_mp"); Client.Other.PrimaryWeapon = weap; Client.Other.CurrentWeapon = weap; } } ProcessSpawn.Remove(key); } } } } }
Posts: 43
Threads: 1
Joined: Dec 2012
Reputation:
0
01-23-2013, 16:09
(This post was last modified: 01-23-2013, 16:12 by ltybcs.)
(01-23-2013, 15:47)8q4s8 Wrote: currentweapon doesn't work with OnPlayerSpawned, you have to use a timer and then give the weapon to the player 1 or 2 seconds after spawn.
I found this code somewhere on itsmods, I think that should work too
CSHARP Code
using System; using System.Collections.Generic; using System.Text; using Addon; namespace ClassLibrary1 { public class Class1:CPlugin { Dictionary <int, int> ProcessSpawn = new Dictionary <int, int>(); public override void OnPlayerSpawned(ServerClient Client) { ProcessSpawn.Add(Client.ClientNum, 1/*seconds*/ * 1000 / AddonFrameInterval); } public override void OnAddonFrame() { List <int> PSKeys = new List <int>(ProcessSpawn. Keys); foreach (int key in PSKeys) { ProcessSpawn[key]--; if (ProcessSpawn[key] == 0) { ServerClient Client = GetClient(key); if (Client.Team == Teams.Allies) { if (Client.XUID == "xxxxxxxxxxxxxxxx") { int weap = GetWeapon("iw5_acr_mp"); Client.Other.PrimaryWeapon = weap; Client.Other.CurrentWeapon = weap; } } ProcessSpawn.Remove(key); } } } } }
Thanks, this script works and considerably reduces the code size as it isn't necessary to register the weapon on each card.
I also added
Client.Other.CurrentWeapon = weapon;
And now the weapon replaces the basic, instead of creates the 3rd for what separate gratitude
|