Samp server.exe closes when i enter a checkpoint
#1

here is my code that makes mys server.exe shutdown:

pawn Код:
public OnPlayerEnterCheckpoint(playerid)
{
    if(Ccp[playerid] == 1) // This checks if our variable equals to 1, if so: it continues
    {
        DisablePlayerCheckpoint(playerid); // This makes sure that there will be a new checkpoint
        Ccp[playerid] = 2; // Changes the variable, so we can use it later again with OnPlayerEnterCheckpoint
        SetPlayerCheckpoint(playerid, -1874.0277,-1675.2848,21.7418, 3.0); // Creates a new checkpoint at a different position
        new rand = RandomEx(0,8);
        SendClientMessage(playerid, COLOR_WHITE, "You have loaded %s materials in your package, Proceed to next pickup.", rand);
    }
    else if(Ccp[playerid] == 2) // This checks if our variable equals to 1, if so: it continues
    {
        DisablePlayerCheckpoint(playerid); // This makes sure that there will be a new checkpoint
        Ccp[playerid] = 3; // Changes the variable, so we can use it later again with OnPlayerEnterCheckpoint
        SetPlayerCheckpoint(playerid, 2085.2393,-2092.6560,13.5309, 3.0); // Creates a new checkpoint at a different position
        new rand = RandomEx(0,13);
        SendClientMessage(playerid, COLOR_WHITE, "You have loaded %s materials in your package, Proceed to next pickup", rand);
    }
    else if(Ccp[playerid] == 3) // This checks if our variable equals to 1, if so: it continues
    {
        DisablePlayerCheckpoint(playerid); // This makes sure that there will be a new checkpoint
        Ccp[playerid] = 4; // Changes the variable, so we can use it later again with OnPlayerEnterCheckpoint
        SetPlayerCheckpoint(playerid, 1354.1035,481.0210,20.2016, 3.0); // Creates a new checkpoint at a different position
        new rand = RandomEx(0,13);
        SendClientMessage(playerid, COLOR_WHITE, "You have loaded %s materials in your package, Proceed to next pickup", rand);
    }
    else if(Ccp[playerid] == 4) // This checks if our variable equals to 1, if so: it continues
    {
        DisablePlayerCheckpoint(playerid); // This makes sure that there will be a new checkpoint
        Ccp[playerid] = 5; // Changes the variable, so we can use it later again with OnPlayerEnterCheckpoint
        SetPlayerCheckpoint(playerid, 2107.0288,-1887.4937,13.5410, 3.0); // Creates a new checkpoint at a different position
        new rand = RandomEx(0,13);
        SendClientMessage(playerid, COLOR_WHITE, "You have loaded %s materials in your package, Proceed to next pickup", rand);
    }
    else if(Ccp[playerid] == 5) // This checks if our variable equals to 1, if so: it continues
    {
        DisablePlayerCheckpoint(playerid); // This makes sure that there will be a new checkpoint
        Ccp[playerid] = 6; // Changes the variable, so we can use it later again with OnPlayerEnterCheckpoint
        SetPlayerCheckpoint(playerid, 2543.7610,-2389.5366,13.6344, 3.0); // Creates a new checkpoint at a different position
        SendClientMessage(playerid, COLOR_WHITE, "You have sucessfully compleated you delivery, Return to LA Docks to get paid");
    }
    else if(Ccp[playerid] == 6) // This checks if our variable equals to 1, if so: it continues
    {
        DisablePlayerCheckpoint(playerid); // This makes sure that there will be a new checkpoint
        Ccp[playerid] = 0; // Changes the variable, so we can use it later again with OnPlayerEnterCheckpoint
        //SetPlayerCheckpoint(playerid, 2543.7610,-2389.5366,13.6344, 3.0); // Creates a new checkpoint at a different position
        new cash = RandomEx(8000,40001);
        SendClientMessage(playerid, COLOR_WHITE, "You have sucessfully compleated you delivery,  LA Docks has paid you $%s and some mats Enjoy!", cash);
        GivePlayerMoney(playerid, cash);
    }
whats the prob?
Reply
#2

pawn Код:
SendClientMessage(playerid, COLOR_WHITE, "You have loaded %s materials in your package, Proceed to next pickup.", rand);
Using specifiers in SendClientMessage(ToAll) functions will crash the server. Format (https://sampwiki.blast.hk/wiki/Format) the text first and send the formatted string.
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
pawn Код:
SendClientMessage(playerid, COLOR_WHITE, "You have loaded %s materials in your package, Proceed to next pickup.", rand);
Using specifiers in SendClientMessage(ToAll) functions will crash the server. Format (https://sampwiki.blast.hk/wiki/Format) the text first and send the formatted string.
Not necessarily. He could be using hooks, or a library that does the hook. Besides, would it compile if he wasn't (number of arguments warning)?

Otherwise, get crashdetect and compile with -d3. Don't understand, please ask. I'm in a bit of a rush at the moment.
Reply
#4

Quote:
Originally Posted by Crayder
Посмотреть сообщение
Not necessarily. He could be using hooks, or a library that does the hook. Besides, would it compile if he wasn't (number of arguments warning)?
Nobody hooks those two functions. All the functions were used for formatted client messages were custom (y_va, #emit and while (FALSE)).

Believe me, many people ignore warnings as their script was compiled. Crashdetect will still print that native SendClientMessage crashes the server, try it out if you want to.
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
pawn Код:
SendClientMessage(playerid, COLOR_WHITE, "You have loaded %s materials in your package, Proceed to next pickup.", rand);
Using specifiers in SendClientMessage(ToAll) functions will crash the server. Format (https://sampwiki.blast.hk/wiki/Format) the text first and send the formatted string.
if you think due to i used %s to display rand, i changed it to %d and testing it now! hope it works
Reply
#6

Except the fact that you've used wrong specifier, that was not the reason of the crash. Using any specifier in client message will crash the server. Use format:
pawn Код:
new string[80];
format(string, sizeof (string), "You have loaded %i materials in your package, Proceed to next pickup.", rand);
SendClientMessage(playerid, -1, string);
Reply
#7

Test passed!! but not 10/10 major problem is rand worked but imit that i have given that not worked?

can you find out problem!!? limit was 0 to 8 materials but it goes to 5........?
Reply
#8

Can you re-post the code after the changes? If %i or %d specifier is used, the only reason it would give such as values would be because of negative max_value in random function and this would give too:
pawn Код:
RandomEx(8,0)
// which would results to value such the one you got
Reply
#9

here's my changed code in place of %s i used %d:
pawn Код:
if(Ccp[playerid] == 1) // This checks if our variable equals to 1, if so: it continues
    {
        DisablePlayerCheckpoint(playerid); // This makes sure that there will be a new checkpoint
        Ccp[playerid] = 2; // Changes the variable, so we can use it later again with OnPlayerEnterCheckpoint
        SetPlayerCheckpoint(playerid, -1874.0277,-1675.2848,21.7418, 3.0); // Creates a new checkpoint at a different position
        new rand = RandomEx(0,8);
        SendClientMessage(playerid, COLOR_WHITE, "You have loaded %d materials in your package, Proceed to next pickup.", rand);
    }
    else if(Ccp[playerid] == 2) // This checks if our variable equals to 1, if so: it continues
    {
        DisablePlayerCheckpoint(playerid); // This makes sure that there will be a new checkpoint
        Ccp[playerid] = 3; // Changes the variable, so we can use it later again with OnPlayerEnterCheckpoint
        SetPlayerCheckpoint(playerid, 2085.2393,-2092.6560,13.5309, 3.0); // Creates a new checkpoint at a different position
        new rand = RandomEx(0,13);
        SendClientMessage(playerid, COLOR_WHITE, "You have loaded %d materials in your package, Proceed to next pickup", rand);
    }
    else if(Ccp[playerid] == 3) // This checks if our variable equals to 1, if so: it continues
    {
        DisablePlayerCheckpoint(playerid); // This makes sure that there will be a new checkpoint
        Ccp[playerid] = 4; // Changes the variable, so we can use it later again with OnPlayerEnterCheckpoint
        SetPlayerCheckpoint(playerid, 1354.1035,481.0210,20.2016, 3.0); // Creates a new checkpoint at a different position
        new rand = RandomEx(0,13);
        SendClientMessage(playerid, COLOR_WHITE, "You have loaded %d materials in your package, Proceed to next pickup", rand);
    }
    else if(Ccp[playerid] == 4) // This checks if our variable equals to 1, if so: it continues
    {
        DisablePlayerCheckpoint(playerid); // This makes sure that there will be a new checkpoint
        Ccp[playerid] = 5; // Changes the variable, so we can use it later again with OnPlayerEnterCheckpoint
        SetPlayerCheckpoint(playerid, 2107.0288,-1887.4937,13.5410, 3.0); // Creates a new checkpoint at a different position
        new rand = RandomEx(0,13);
        SendClientMessage(playerid, COLOR_WHITE, "You have loaded %d materials in your package, Proceed to next pickup", rand);
    }
    else if(Ccp[playerid] == 5) // This checks if our variable equals to 1, if so: it continues
    {
        DisablePlayerCheckpoint(playerid); // This makes sure that there will be a new checkpoint
        Ccp[playerid] = 6; // Changes the variable, so we can use it later again with OnPlayerEnterCheckpoint
        SetPlayerCheckpoint(playerid, 2543.7610,-2389.5366,13.6344, 3.0); // Creates a new checkpoint at a different position
        SendClientMessage(playerid, COLOR_WHITE, "You have sucessfully compleated you delivery, Return to LA Docks to get paid");
    }
    else if(Ccp[playerid] == 6) // This checks if our variable equals to 1, if so: it continues
    {
        DisablePlayerCheckpoint(playerid); // This makes sure that there will be a new checkpoint
        Ccp[playerid] = 0; // Changes the variable, so we can use it later again with OnPlayerEnterCheckpoint
        //SetPlayerCheckpoint(playerid, 2543.7610,-2389.5366,13.6344, 3.0); // Creates a new checkpoint at a different position
        new cash = RandomEx(8000,40001);
        SendClientMessage(playerid, COLOR_WHITE, "You have sucessfully compleated you delivery,  LA Docks has paid you $%d and some mats Enjoy!", cash);
        GivePlayerMoney(playerid, cash);
    }
EDIT:How can i restrict this cmd only if player is in carid 499(warehouse truck)
Код:
CMD:loadmats(playerid, params[])
{
    new vehicleid = GetPlayerVehicleID(playerid);
	if(IsPlayerInRangeOfPoint(playerid, 5.0, 2568.7224,-2419.9768,13.6341))
	{
	if(IsAWarehouseTruck(vehicleid))
	{
	if(PlayerInfo[playerid][pJob] != 4)
	{
		SendClientMessage(playerid, COLOR_WHITE, "You are not a Warehouse worker!");
	}
	else
	{
		SendClientMessage(playerid, COLOR_WHITE, "You have picked a material's package, Proceed to next pickup");
        SetPlayerCheckpoint(playerid, 2311.5037,-74.1533,26.4751, 3.0);
		Ccp[playerid] = 1;
 	}
 	}
	else SendClientMessage(playerid, COLOR_WHITE, "You need to be inside a Warehouse truck to pick a materials package!");
	}
	else SendClientMessage(playerid, COLOR_WHITE, "You are not at the package loading point!");
	return 1;
}
currently i use this code to specify IsAWarehouseTruck:
Код:
IsAWarehouseTruck(carid)
{
	if(carid == 499) return 1;
}
And it comes wth a warning that it should return a value!when i use this it says you are not in a warehouse truck even i am in carid 499?
Reply
#10

Man, I told you to use format: http://forum.sa-mp.com/showpost.php?...96&postcount=6
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)