View Single Post
Old 23/05/2019, 05:42 PM   #7
Plastikmensch
Huge Clucker
 
Join Date: Aug 2016
Posts: 272
Reputation: 22
Default Re: Help Server crashing

Hmh, I see really bad practice but nothing that would crash the server. What is inside the Robbery function?
Some tips:
You don't need to check if a player has a specific skin and then check if a player has not that skin.
Code:
If(skinid==300 || ...)
else
is sufficient. Also a switch-case is probably better for this
Code:
switch(GetPlayerSkin(playerid))
{
   case 300 .. 311:
   {
      //SendMessage
   }
   default:
   {
      //StartRobbery
   }
}
There is a lot of repetition. Create an array and store the coordinates in it.
Code:
new Float:robberyLocations[][3] = {
   {<x>,<y>,<z>},
   ...
};
Then you can do:
Code:
for(new i=0,j=sizeof(robberyLocations);i<j;i++)
{
   if(IsPlayerInRangeOfPoint(playerid,10.0,robberyLocations[i][0],robberyLocations[i][1],...)
   {
      //DoStuff
   }
}
And you can delete params[] in the command since you don't use any.
Code:
CMD:robbery(playerid)

Last edited by Plastikmensch; 24/05/2019 at 12:52 AM. Reason: fixed mistake
Plastikmensch is offline   Reply With Quote