PDA

View Full Version : Samp server.exe closes when i enter a checkpoint


GTLS
17/05/2015, 01:03 PM
here is my code that makes mys server.exe shutdown:


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?

Konstantinos
17/05/2015, 01:05 PM
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://wiki.sa-mp.com/wiki/Format) the text first and send the formatted string.

Crayder
17/05/2015, 01:57 PM
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://wiki.sa-mp.com/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.

Konstantinos
17/05/2015, 02:04 PM
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.

GTLS
17/05/2015, 03:12 PM
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://wiki.sa-mp.com/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

Konstantinos
17/05/2015, 03:15 PM
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:

new string[80];
format(string, sizeof (string), "You have loaded %i materials in your package, Proceed to next pickup.", rand);
SendClientMessage(playerid, -1, string);

GTLS
17/05/2015, 03:23 PM
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........?

Konstantinos
17/05/2015, 03:34 PM
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:

RandomEx(8,0)
// which would results to value such the one you got

GTLS
17/05/2015, 03:43 PM
here's my changed code in place of %s i used %d:

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?

Konstantinos
17/05/2015, 03:45 PM
Man, I told you to use format: http://forum.sa-mp.com/showpost.php?p=3461596&postcount=6

GTLS
17/05/2015, 05:11 PM
Man, I told you to use format: http://forum.sa-mp.com/showpost.php?p=3461596&postcount=6

Thanks dude this tie it gives me correct amount mats!!

and by the way how can i make that if player is in warehouse truck (carid 499) then only /loadmats cmd works else it says error message?

Konstantinos
17/05/2015, 05:32 PM
https://wiki.sa-mp.com/wiki/GetVehicleModel


if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 499)
{
// player is in "Benson" vehicle model.. code
}

GTLS
18/05/2015, 08:17 AM
https://wiki.sa-mp.com/wiki/GetVehicleModel


if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 499)
{
// player is in "Benson" vehicle model.. code
}



You rule buddy your just awesome!!!!! **CHEERS**:D:o;):D:):cool:;D:rolleyes:8):clucker: