Spawning with a weapon isn't working
#1

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.
Reply
#2

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

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
Reply
#4

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.
Reply
#5

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

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.
Reply
#7

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
Reply
#8

Any other includes or anything?
Reply
#9

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)