How is s0beit spawning a weapon ?

.silent

Well-known member
Joined
Apr 14, 2013
Messages
339
Reaction score
13
Hi !
Im creating my second sa-mp trainer, with much more functions.
I want to add a weapon spawn, just like in s0beit.The problem is that i dont even have the VC++ IDE and i dont even have the s0beit source.How is s0b spawning the weapons for player ? Is it using just memory addresses ?
I found this on the addresses site:
Code:
WeaponSlot                 // Total 28Bytes
 DWORD       type          // + 0
 DWORD       state         // + 4 (0 idle, 1 firing, 2 reloading)
 DWORD       AmmoInClip    // + 8
 DWORD       AmmoRemaining // +12
 FLOAT       unknown       // +16 (increases each time you fire your weapon, 0 when weapon not active, 
                              probably used to count bullets fired to know when to reload?)
 UNKNOWN     0..7 Bytes    // +20 (unknown - goggle mode, 0 off and 256 on)...+27

WeaponSlot.type
  (Slot0: No Weapon)                    (Slot2: Handguns)
  0 - Fist                               22 - Pistol
  1 - Brass Knuckles                     23 - Silenced Pistol
  (Slot1: Melee)                         24 - Desert Eagle
  2 - Golf Club                         (Slot3: Shotguns)
  3 - Nitestick                          25 - Shotgun
  4 - Knife                              26 - Sawn-Off Shotgun
  5 - Baseball Bat                       27 - SPAS-12
  6 - Shovel                            (Slot4: Sub-Machineguns)
  7 - Pool Cue                           28 - Micro Uzi 
  8 - Katana                             29 - MP5
  9 - Chainsaw                           32 - TEC-9
  15 - Cane
  (Slot5: Machineguns)                   (Slot10: Gifts)
  30 - AK47                              14 - Flowers
  31 - M4                                (Slot9:Special1)
  (Slot6: Rifles)                        42 - Fire Extinguisher
  33 - Country Rifle                     43 - Camera 
  34 - Sniper Rifle                      (Slot11:Special2)
  (Slot7: Heavy Weapons)                 44 - NV Goggles
  35 - Rocket Launcher                   45 - IR Goggles
  36 - Heat Seaking RPG                  46 - Parachute
  37 - Flame Thrower                     (Slot12:Detonators)
  38 - Minigun                            40 - Detonator(for remote explosives)
  (Slot8: Projectiles)
  16 - Grenade
  18 - Molotov Cocktail
  39 - Remote Explosives
  (No slot: Fired from hunter / hydra / missile launcher)
  (This type is stored in the rocket pool as rocket type, but is the continuation of this list)
  19 - Normal rockets
  20 - Heatseeking rockets
  58 - Flares
But i have no idea how to use it to spawn a weapon.
(I dont want any code, just a explanation for doing this like, you have to write this to this address etc)
 

Wut

Well-known member
Joined
Mar 1, 2013
Messages
338
Reaction score
1
Code:
#include <cstdlib>
#include <iostream>
#include <windows.h>

#define gProc hProc //lol ye examples and source codes sometimes confusing me
#define ALT VK_MENU
HWND GTASA;

using namespace std;

int money = 0xB7CE50;
int gravity = 0x863984;
int wep1 = 0x969130;
int wep2 = 0x969131;
int wep3 = 0x969132;


bool get_gta_window(HWND GTA)
{
    GTA = FindWindow(NULL, "GTA:SA");
    if(!GTA)
    {
        MessageBox(NULL, "GTA San Andreas not found.", "FAIL", MB_ICONERROR);
        MessageBox(NULL, "Exitig.", "FAIL", MB_ICONERROR);
        MessageBox(NULL, "trololo.", "FAIL", MB_ICONERROR);
        exit(0);
    }
}

void give_monkey(int amt)
{
    DWORD dwID;
    HANDLE hProc;

    HWND sa;
    get_gta_window(sa);
    GetWindowThreadProcessId(sa, &dwID);
    hProc = OpenProcess(PROCESS_ALL_ACCESS, 0, dwID);
    WriteProcessMemory(hProc, (LPVOID)money, (LPVOID)amt, sizeof(amt), NULL );

}

void change_gravity(int amt)
{
    DWORD dwID;
    HANDLE hProc;

    HWND sa;
    get_gta_window(sa);
    GetWindowThreadProcessId(sa, &dwID);
    hProc = OpenProcess(PROCESS_ALL_ACCESS, 0, dwID);
    WriteProcessMemory(hProc, (LPVOID)gravity, (LPVOID)amt, sizeof(amt), NULL );

}

void give_weapon_set(int which_one)
{
     DWORD dwID;
    HANDLE hProc;

    HWND sa;
    get_gta_window(sa);
    GetWindowThreadProcessId(sa, &dwID);
    hProc = OpenProcess(PROCESS_ALL_ACCESS, 0, dwID);
    
    switch(which_one)
    {
        case 1:
        WriteProcessMemory(hProc, (LPVOID)wep1, (LPVOID)1, sizeof(1), NULL );
        break;
        
        case 2:
        WriteProcessMemory(hProc, (LPVOID)wep2, (LPVOID)1, sizeof(1), NULL );
        break;
        
        case 3:
        WriteProcessMemory(hProc, (LPVOID)wep3, (LPVOID)1, sizeof(1), NULL );
        break;
   }
}


void get_hot_keys()
{
while(1)
            {
                if(GetAsyncKeyState(ALT) && GetAsyncKeyState(VK_F1))
                {
                        give_monkey(99999);
                }
                

                if(GetAsyncKeyState(ALT) && GetAsyncKeyState(VK_F2))
                {
                       change_gravity(200);
                }
                
                if(GetAsyncKeyState(ALT) && GetAsyncKeyState(VK_F3))
                {
                        give_weapon_set(1);
                }
                if(GetAsyncKeyState(ALT) && GetAsyncKeyState(VK_F4))
                {
                        give_weapon_set(2);
                }
                if(GetAsyncKeyState(ALT) && GetAsyncKeyState(VK_F5))
                {
                        give_weapon_set(3);
                }
            }
}


int main(int argc, char *argv[])
{
    printf("ALT + F1 for 999999 moneynALT + F2 low gravitynALT + F3 weapon set 1nALT + F4 weapon set 2nALT + F5 weapon set 3");
    while(1)
    {
            if(get_gta_window(GTASA))
            { 
            get_hot_keys();
             }
            
    }
}

Code stolen from the internet, maybe it will help
 

.silent

Well-known member
Joined
Apr 14, 2013
Messages
339
Reaction score
13
If you could maybe know, weapon sets wont work in SA-MP and i was talking about spawning single weapons and i know how to do it since very long time.
 
Top