SA-MP Forums Archive
Spawning with a weapon isn't working - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Spawning with a weapon isn't working (/showthread.php?tid=267807)



Spawning with a weapon isn't working - cloudysky - 09.07.2011

pawn Код:
stock SpawnWeapons(playerid)
{
    if(PlayerInfo[playerid][New] == 0)
    {
        GivePlayerWeapon(playerid, 28, 1000);
        GivePlayerWeapon(playerid, 22, 9999);
        PlayerInfo[playerid][New] = 1;
    }
    return 1;
}
and OnPlayerSpawn i have this

pawn Код:
SpawnWeapons(playerid);
Anyone know why this isn't working.


Re: Spawning with a weapon isn't working - Calgon - 10.07.2011

Are you sure that your variable 'PlayerInfo[playerid][New]' for that player is equal to 0?


Re: Spawning with a weapon isn't working - cloudysky - 10.07.2011

Thanks for the quick response,

Yes it is

EDIT: It's like it skips the whole function because it doesn't turn 1. I tried it without the stock as well


Re: Spawning with a weapon isn't working - Calgon - 10.07.2011

Try this code:

pawn Код:
stock SpawnWeapons(playerid)
{
    print("test call from SpawnWeapons - the code works prior to the if statement");
    if(PlayerInfo[playerid][New] == 0)
    {
        print("test call from SpawnWeapons - the code works from inside the if statement");
        GivePlayerWeapon(playerid, 28, 1000);
        GivePlayerWeapon(playerid, 22, 9999);
        PlayerInfo[playerid][New] = 1;
    }
    return 1;
}
Check your server_log.txt to see whether the prints show up.


Re: Spawning with a weapon isn't working - cloudysky - 10.07.2011

Both show up so its reading it but not actually doing anything.


Re: Spawning with a weapon isn't working - Calgon - 10.07.2011

Do you have any sort of anticheat code that would disarm the player of their weapon if it's not properly registered? An example of this could be an anticheat from an admin filterscript.


Re: Spawning with a weapon isn't working - cloudysky - 10.07.2011

No, no filterscripts or anticheats (yet) this is the first time I've tried to add weapons.

EDIT: I made a command earlier and that worked fine, if that helps at all


Re: Spawning with a weapon isn't working - Calgon - 10.07.2011

Any other includes or anything?


Re: Spawning with a weapon isn't working - cloudysky - 10.07.2011

No nothing but my GM

EDIT: Never mind I will find another way to give the player weapons once they are in game. Thanks for the help and for your time