Spawnwep System by Mack
[Gamedig] VCMP Activity Monitor »

Mack

  • Newbie
  • Posts: 11
Spawnwep System by Mack
« on January 16th, 2016, 02:38 AM »
Hello, I go back again lol.


> First copy this lines and paste on "onScriptLoad()"
Code: [Select]
  db <- ConnectSQL( "Spawnwep.db" );
  QuerySQL( db,"CREATE TABLE IF NOT EXISTS Spawnwep( Nick TEXT, Weps TEXT)");
  SpawnwepPlayer <- array( GetMaxPlayers(), null );

> Now copy this line and paste on "onPlayerJoin( player )"
Code: [Select]
LoadSpawnwep(player);

> Paste this on "onPlayerSpawn( player )"
Code: [Select]
GiveSpawnwep(player);

> And now paste this on "onPlayerPart( player, reason )"
Code: [Select]
if (SpawnwepPlayer[ player.ID ] != null)
{
if(!CheckTableSpawnwep( player )) QuerySQL( db, "REPLACE INTO Spawnwep( Nick, Weps ) VALUES ( '" + player.Name + "','"+ SpawnwepPlayer[ player.ID ] + "' ) ");
else QuerySQL( db, "UPDATE Spawnwep SET Weps='"+ SpawnwepPlayer[ player.ID ] +"' WHERE Nick='" + player.Name + "'" );
SpawnwepPlayer[ player.ID ] = null; print( player.Name +"'s Spawnwep Saved!" );
}



Code: [Select]
//=================================SPAWNWEP STSTEM BY MACK==========================================================
function CheckTableSpawnwep( player )
{
    local si = GetSQLColumnData( QuerySQL( db, "SELECT Weps FROM Spawnwep WHERE Nick='" + player.Name + "'" ), 0 );
    if ( si ) return si;
    else return 0;
}
//-------------------------------------------------------------------------------------------------------------------
function LoadSpawnwep(player)
{
if(CheckTableSpawnwep( player )) SpawnwepPlayer[ player.ID ] = CheckTableSpawnwep( player );
else SpawnwepPlayer[ player.ID ] = null;
}
//-------------------------------------------------------------------------------------------------------------------
function GiveSpawnwep(player)
{
if (SpawnwepPlayer[ player.ID ] != null)
{
local i = 1, khe = SpawnwepPlayer[ player.ID ], Nweps = NumTok( khe," ");
while ( i < (Nweps.tointeger()+1))
{
local ID = GetTok( khe," ", i);
player.SetWeapon( ID.tointeger(), 99999 ); i++;
}
ClientMessage("-> [#83bab3][SPAWNWEP] Weapons setting in spawn, Completed successfully.",player,255,0,102);
}
}
//=================================SPAWNWEP STSTEM BY MACK==========================================================

> Credits to original creator of this functions.
Code: [Select]
//-------------------------------------------------------------------------------------------------------------------
function NumTok(string, separator)
{
    local tokenized = split(string, separator);
    return tokenized.len();
}
//-------------------------------------------------------------------------------------------------------------------
function GetPlayer( target )
{
local target1 = target.tostring();

if ( IsNum( target ) )
{
target = target.tointeger();

if ( FindPlayer( target) ) return FindPlayer( target );
else return null;
}
else if ( FindPlayer( target ) ) return FindPlayer( target );
else return null;
}
//-------------------------------------------------------------------------------------------------------------------

> Commands: /spawnwep, /spawnwepdel. <
Code: [Select]
if ( cmd == "spawnwep" )
    {
       
  if ( !text ) ClientMessage( "[#ea4335]-> Error: [#fbbc05]Type /spawnwep <Wep1> <Wep2> <Wep3> <Wep4> <Wep5> <Wep6>...", player,0,0,0 );
        else
        {
            local weps = split( text, " " ),ID, wepsset = null;
            for( local i = 0; i < weps.len(); i++ )
            {
                ( IsNum( weps[ i ] ) ) ? ID = weps[ i ].tointeger() : ID = GetWeaponID( weps[ i ] );                         
                if ( ID >= 33 ) ClientMessage( "[#ea4335]-> Error: [#c0c0c0]Invalid Weapon ID/Name.", player,0,0,0 );
                else
                {
                    player.SetWeapon( ID, 99999 );
                    ClientMessage( "-> [#daff00]Saving " + GetWeaponName( ID ) + " to your spawn.",player,255,0,102);
                    if (wepsset == null) wepsset = " "+ ID;
                    else wepsset += (" " + ID);
                }
            }
            if (wepsset) SpawnwepPlayer[ player.ID ] = wepsset;   
        }
    }
    else if ( cmd == "spawnwepdel")
    {

    if ( CheckTableSpawnwep( player ) )
    {
        QuerySQL( db, "DELETE FROM SpawnWep WHERE Nick='" + player.Name + "' COLLATE NOCASE" );
        ClientMessage( "-> Your Spawnwep have been deleted.",player,255,0,102); SpawnwepPlayer[ player.ID ] = null;
    }
    else ClientMessage( "-> Error: You not have spawnwep.",player,255,0,102);
    }

And the end would look like this.





I tested this script and work :)
Dowload Script: Mediafire
Virus Total: Link

Williams

  • Jr. Member
  • #GiveRespectGetRespect
  • Posts: 82
Hey, i m always at IRC and Forum you can comtact me at IRC channel :- #GDM @LUNet and Forum :- http://pro-fighter.tk/index.php

Mack

  • Newbie
  • Posts: 11

KAKAN

  • Wiki Contributor
  • Posts: 3,343
oh no

Xmair

  • Wiki Contributor
  • Posts: 938

Credits to Boystang!

VU Full Member | VCDC 6 Coordinator & Scripter | EG A/D Contributor | Developer of VCCNR | Developer of KTB | Ex-Scripter of EAD

Anik

  • Sr. Member
  • Posts: 356
Re: Spawnwep System by Mack
« Reply #5, on January 16th, 2016, 10:14 AM »
Off:- Which SOftware are u using for editing scripts?? Can u give me Download Link??

Drake

  • Beta Tester Emeritus
  • Posts: 287
Re: Spawnwep System by Mack
« Reply #6, on January 16th, 2016, 10:44 AM »
Quote from [DS]Anik on January 16th, 2016, 10:14 AM
Off:- Which SOftware are u using for editing scripts?? Can u give me Download Link??
The software's name is clearly written in one of the images, Hint: title ;D

Mack

  • Newbie
  • Posts: 11

Sebastian

  • VC:MP Beta Tester
  • Something like this: hga hga hga
  • Posts: 1,105
Re: Spawnwep System by Mack
« Reply #8, on January 16th, 2016, 07:52 PM »
* sseebbyy likes very much the presentation of script.

ps: you could still add some more info about how the script works.

KAKAN

  • Wiki Contributor
  • Posts: 3,343
oh no

doxuanhien2002

  • Newbie
  • Posts: 9

Gitobaloch

  • Full Member
  • Posts: 100
Re: Spawnwep System by Mack
« Reply #11,  »
im getting bug
AN ERROR HAS OCCURED [cannot convert the string]

CALLSTACK
*FUNCTION [GiveSpawnwep()] scripts/main.nut line [124]
*FUNCTION [onPlayerSpawn()] scripts/main.nut line [370]

LOCALS
[ID] ""
[Nweps] 3
[khe] " 26 20"
1
[player] INSTANCE
[this] TABLE
[player] INSTANCE
Developer of Great VFS!


free png image com

habi

  • Sr. Member
  • Posts: 290

=RK=MarineForce

  • Sr. Member
  • WAR IS HELL!
  • Posts: 462
Try to UnderStand ME!

habi

  • Sr. Member
  • Posts: 290