Command which crashes the server..
#1

Hello, one of the commands we added to the server (/duel) makes the server CRASH..
Do you guys have any idea why? or you can help me to solve it ?
here's the command:

Код:
CMD:duel(playerid, params[])
{
	new id, id2, weapon;
	if(PlayerInfo[playerid][pAdmin] >=3)
	{
		if (sscanf(params, "uii", id, id2, weapon)) SendClientMessage(playerid, COLOR_GREY, "** [Usage]: /duel [playerid/name] [playerid/name] [Weapon]");
	 	else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_LIGHTRED, "** [Error]: Player One not found");
	 	else if (id2 == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_LIGHTRED, "** [Error]: Player Two not found");
		else
		{
		    SetPlayerPos(playerid, 1374.0948,5.5511,1008.1563);
			SetPlayerPos(id, 1413.1495,-15.9198,1000.9246);
			SetPlayerPos(id2, 1367.6084,-17.7317,1000.9219);
			SetPlayerHealth(id, 100);
			SetPlayerHealth(id2, 100);
			SetPlayerArmour(id, 100);
			SetPlayerArmour(id2, 100);
			ResetPlayerWeapons(id);
			ResetPlayerWeapons(id2);
			GivePlayerValidAdminWeapon(id, weapon);
			GivePlayerValidAdminWeapon(id2, weapon);
			GameTextForPlayer(id, "~r~DUEL ON", 2000, 4);
			GameTextForPlayer(id2, "~r~DUEL ON", 2000, 4);
			SetPlayerInterior(id, 1);
			SetPlayerInterior(id2, 1);
			SetPlayerInterior(playerid, 1);
			SetPlayerVirtualWorld(playerid, 0);
			SetPlayerVirtualWorld(id, 0);
			SetPlayerVirtualWorld(id2, 0);
			return 1;
		}
		return 1;
	}
	else
	{
		SendClientMessage(playerid, COLOR_LIGHTRED, "** [Error]: You are NOT a Level 3+ admin");
		return 1;
	}
}
Reply
#2

could you please provide server log
Reply
#3

pawn Код:
CMD:duel(playerid, params[])
{
    new id, id2, weapon;
    if(PlayerInfo[playerid][pAdmin] >=3)
    {
        if(sscanf(params, "uii", id, id2, weapon)) SendClientMessage(playerid, COLOR_GREY, "** [Usage]: /duel [playerid/name] [playerid/name] [Weapon]");
        if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_LIGHTRED, "** [Error]: Player One not found");
        if(id2 == INVALID_PLAYER_ID) SendClientMessage(playerid, COLOR_LIGHTRED, "** [Error]: Player Two not found");
        SetPlayerPos(playerid, 1374.0948,5.5511,1008.1563);
        SetPlayerPos(id, 1413.1495,-15.9198,1000.9246);
        SetPlayerPos(id2, 1367.6084,-17.7317,1000.9219);
        SetPlayerHealth(id, 100);
        SetPlayerHealth(id2, 100);
        SetPlayerArmour(id, 100);
        SetPlayerArmour(id2, 100);
        ResetPlayerWeapons(id);
        ResetPlayerWeapons(id2);
        GivePlayerValidAdminWeapon(id, weapon);
        GivePlayerValidAdminWeapon(id2, weapon);
        GameTextForPlayer(id, "~r~DUEL ON", 2000, 4);
        GameTextForPlayer(id2, "~r~DUEL ON", 2000, 4);
        SetPlayerInterior(id, 1);
        SetPlayerInterior(id2, 1);
        SetPlayerInterior(playerid, 1);
        SetPlayerVirtualWorld(playerid, 0);
        SetPlayerVirtualWorld(id, 0);
        SetPlayerVirtualWorld(id2, 0);
    }
    else
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "** [Error]: You are NOT a Level 3+ admin");
        return 1;
    }
}
Try this, and post server logs as the above poster said.
Reply
#4

Hey, I used the edit that the poster ^ gave me, it works.. not crashing but...
First player gets weapon with i think 20 ammo,
The second one gets Weapon with 1 ammo..

How Do i Fix this?

I want it to be same amount of ammo, for example 30 bullets for everyone..
Or even better to make un-limited.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)