SA-MP Forums Archive
[HELP] weapons - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [HELP] weapons (/showthread.php?tid=660370)



[HELP] weapons - zakariacaspeer - 01.11.2018

How the players get the auto weapons
At spawn players
Can you help me with a service to give the players weapons?
for example :
cmd:weaponset
with save weapons



Re: [HELP] weapons - TheToretto - 01.11.2018

What weapons do you need khoya ?


Re: [HELP] weapons - UFF - 01.11.2018

Random Weapons on Spawn
pawn Code:
new RandomWeapons[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
RandomWeapons[playerid] = 0;
return 1;
}


public OnPlayerSpawn(playerid)
{
 GivePlayerSpawnWeapons(playerid);
 return 1;
}

stock GivePlayerSpawnWeapons(playerid)
{
   switch(RandomWeapons[playerid])
   {
        case 0:
        {
                 // Random Weapons 1
                 RandomWeapons[playerid]++; // Increases the RandomWeapon value to 1,
        }
        case 1:
        {
               // Random Weapons 2
               RandomWeapons[playerid] = 0; // Reset to Value 0 , so it will give Random Weapon 1 weapons again when player spawns.
        }
   }
}



Re: [HELP] weapons - TheToretto - 01.11.2018

Quote:
Originally Posted by UFF
View Post
Random Weapons on Spawn
pawn Code:
new RandomWeapons[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
RandomWeapons[playerid] = 0;
return 1;
}


public OnPlayerSpawn(playerid)
{
 GivePlayerSpawnWeapons(playerid);
 return 1;
}

stock GivePlayerSpawnWeapons(playerid)
{
   switch(RandomWeapons[playerid])
   {
        case 0:
        {
                 // Random Weapons 1
                 RandomWeapons[playerid]++; // Increases the RandomWeapon value to 1,
        }
        case 1:
        {
               // Random Weapons 2
               RandomWeapons[playerid] = 0; // Reset to Value 0 , so it will give Random Weapon 1 weapons again when player spawns.
        }
   }
}
The fuck? Firstly there is no absolute "GivePlayerWeapon" native in your code, from where do you want to get the weapon? Then, weapons IDs are limited between 1 and 46, and thirdly I don't understand a shit in your switch statement, sorry :/


Re: [HELP] weapons - UFF - 01.11.2018

Quote:
Originally Posted by TheToretto
View Post
The fuck? Firstly there is no absolute "GivePlayerWeapon" native in your code, from where do you want to get the weapon? Then, weapons IDs are limited between 1 and 46, and thirdly I don't understand a shit in your switch statement, sorry :/
I just gave him the outline of the code.

here is it.
pawn Code:
stock GivePlayerSpawnWeapons(playerid)
{
   switch(RandomWeapons[playerid])
   {
        case 0:
        {
                 // Random Weapons 1
                 GivePlayerWeapon(playerid, 31, 500); // M4
         GivePlayerWeapon(playerid, 24, 400); // Deagle
                 RandomWeapons[playerid]++; // Increases the RandomWeapon value to 1,
        }
        case 1:
        {
               // Random Weapons 2
        GivePlayerWeapon(playerid, 32, 800); // TEC-9
        GivePlayerWeapon(playerid, 26, 20); // SawnOff
               RandomWeapons[playerid] = 0; // Reset to Value 0 , so it will give Random Weapon 1 weapons again when player spawns.
        }
   }
}
Atleast let him learn something instead of giving him the whole code and he will just copy and paste it.


Re: [HELP] weapons - TheToretto - 01.11.2018

Quote:
Originally Posted by UFF
View Post
I just gave him the outline of the code.

here is it.
pawn Code:
stock GivePlayerSpawnWeapons(playerid)
{
   switch(RandomWeapons[playerid])
   {
        case 0:
        {
                 // Random Weapons 1
                 GivePlayerWeapon(playerid, 31, 500); // M4
         GivePlayerWeapon(playerid, 24, 400); // Deagle
                 RandomWeapons[playerid]++; // Increases the RandomWeapon value to 1,
        }
        case 1:
        {
               // Random Weapons 2
        GivePlayerWeapon(playerid, 32, 800); // TEC-9
        GivePlayerWeapon(playerid, 26, 20); // SawnOff
               RandomWeapons[playerid] = 0; // Reset to Value 0 , so it will give Random Weapon 1 weapons again when player spawns.
        }
   }
}
Atleast let him learn something instead of giving him the whole code and he will just copy and paste it.
That's not really a "random weapons" because what you made will give the player after a death, first time a deagle & m4, then a tec9 & sawn etcetera, it'll remain the same.


Re: [HELP] weapons - zakariacaspeer - 01.11.2018

Quote:
Originally Posted by TheToretto
View Post
What weapons do you need khoya ?
i need sawn sniper desert m4 ...
and ty khoya


Re: [HELP] weapons - zakariacaspeer - 01.11.2018

ty guys


Re: [HELP] weapons - TheToretto - 01.11.2018

Quote:
Originally Posted by zakariacaspeer
View Post
i need sawn sniper desert m4 ...
and ty khoya
If you need it as a command:

pawn Code:
CMD:weaponset(playerid, params[])
{
    GivePlayerWeapon(playerid, 24, 200);    
    GivePlayerWeapon(playerid, 26, 200);    
    GivePlayerWeapon(playerid, 34, 200);    
    GivePlayerWeapon(playerid, 31, 500);    

    SendClientMessage(playerid, -1, "You've just loaded the weapon set 1!");
    return 1;
}



Re: [HELP] weapons - zakariacaspeer - 01.11.2018

ty bro


Re: [HELP] weapons - d3Pedro - 01.11.2018

Quote:
Originally Posted by TheToretto
View Post
If you need it as a command:

pawn Code:
CMD:weaponset(playerid, params[])
{
    GivePlayerWeapon(playerid, 24, 200);    
    GivePlayerWeapon(playerid, 26, 200);    
    GivePlayerWeapon(playerid, 34, 200);    
    GivePlayerWeapon(playerid, 31, 500);    

    SendClientMessage(playerid, -1, "You've just loaded the weapon set 1!");
    return 1;
}
The point is making them learn how does this really work instead of just giving them the code, because next time he will ask again.

OT: Search Before posting!
There's a wiki for that, have a look at > https://sampwiki.blast.hk/wiki/GivePlayerWeapon
There's also a anti weapon hack tutorial, have a look at > https://sampforum.blast.hk/showthread.php?tid=319800


Re: [HELP] weapons - zakariacaspeer - 01.11.2018

Quote:
Originally Posted by TheToretto
View Post
The fuck? Firstly there is no absolute "GivePlayerWeapon" native in your code, from where do you want to get the weapon? Then, weapons IDs are limited between 1 and 46, and thirdly I don't understand a shit in your switch statement, sorry :/
Code:
C:\Documents and Settings\Administrateur\Bureau\MORROCAIN STUNTING\gamemodes\blank.pwn(1813) : error 021: symbol already defined: "MP_OPC"
C:\Documents and Settings\Administrateur\Bureau\MORROCAIN STUNTING\gamemodes\blank.pwn(2215) : error 021: symbol already defined: "OnPlayerSpawn"



Re: [HELP] weapons - TheToretto - 01.11.2018

Quote:
Originally Posted by zakariacaspeer
View Post
Code:
C:\Documents and Settings\Administrateur\Bureau\MORROCAIN STUNTING\gamemodes\blank.pwn(1813) : error 021: symbol already defined: "MP_OPC"
C:\Documents and Settings\Administrateur\Bureau\MORROCAIN STUNTING\gamemodes\blank.pwn(2215) : error 021: symbol already defined: "OnPlayerSpawn"
You used the code of UFF, use mine.

And to explain your errors: You already have in your actual gamemode both "public OnPlayerSpawn(playerid)" and "public OnPlayerConnect(playerid)" (OPC) so you have to CTRL + F them then insert the code, or simply use mine as it doesn't need any callback.

@ConnorW - I thought the native explains itself ^^


Re: [HELP] weapons - zakariacaspeer - 01.11.2018

tyyyyyyyyyyyy bro


Re: [HELP] weapons - zakariacaspeer - 01.11.2018

Quote:
Originally Posted by ConnorW
View Post
The point is making them learn how does this really work instead of just giving them the code, because next time he will ask again.

OT: Search Before posting!
There's a wiki for that, have a look at > https://sampwiki.blast.hk/wiki/GivePlayerWeapon
There's also a anti weapon hack tutorial, have a look at > https://sampforum.blast.hk/showthread.php?tid=319800
The only easy step is transportation