forward AutoWeather();
SetTimer("AutoWeather", 600000, 1);
AutoWeather();
public AutoWeather()
{
new RandonWeather = random(15);
SetWeather(RandonWeather);
}
|
Originally Posted by Y_Leѕѕ
OnServerFrame
This little snippet will cause a callback to be called every server frame. It's operation is fairly obvious as long as you know that sleep(0) does not sleep for exactly 0ms but just >= 0, i.e. it will be called at the next frame greater than 0ms later, not instantly. For this reason the example below may have larger than 0ms gaps (0 is obviously impossible).This must be put in all your gamemodes if you want it to work consistently, or you can just use th next version of the YSI plugin which will likely include this: pawn Код:
pawn Код:
|
main()
{
SetTimer( "OnServerFrame", 1, 1 );
}
|
Originally Posted by Seif_
Is that some total bullcrap? I made this on my own in January.
|

stock exRPKick(playerid)
{
if (IsPlayerConnected(playerid))
{
new player[24], illegal = 0, legal = 0;
GetPlayerName(playerid, player, 24);
for(new n=0; n<=strlen(player); n++)
{
if(player[n] == '_') legal += 1;
if(player[n] == '[' || player[n] == ']') illegal += 1;
if(player[n] == '{' || player[n] == '}') illegal += 1;
}
if(illegal >= 1)
{
SendClientMessage(playerid,0xE60000FF,"Wrong name format. Please reconnect using the correct name format like this: Firstname_Lastname");
SendClientMessage(playerid,0x33AA33AA,"Example: Michael_Taylor");
Kick(playerid);
return 1;
}
if(legal >= 1 && illegal <= 0) return 1;
}
return 1;
}

PlayerExecute(playerid,command[])
{
if(command[0] == '/')
{
CallRemoteFunction("OnPlayerCommandText", "is", playerid, command);
}
else
{
CallRemoteFunction("OnPlayerText","is",playerid,command);
}
return 1;
}
public OnPlayerUpdate(playerid)
{
new string[128];
new pName[16];
GetPlayerName(playerid, pName, sizeof(pName));
if(GetPlayerPing(playerid) >= 300)
{
format(string, sizeof(string), "*** %s has bin kicked for Too high ping (max 300)", pName);
SendClientMessageToAll(COLOR_RED, string);
SendClientMessage(playerid, COLOR_RED, "you have bin kicked for too high ping");
Kick(playerid);
}
return 1;
}
new Float:CarHealth[MAX_PLAYERS];
public OnPlayerUpdate(playerid)
{
if(IsPlayerInAnyVehicle(playerid) == 1)
{
new Float:TempCarHealth;
GetVehicleHealth(GetPlayerVehicleID(playerid), TempCarHealth);
new Float:Difference = floatsub(CarHealth[playerid], TempCarHealth);
if((floatcmp(CarHealth[playerid], TempCarHealth) == 1) && (floatcmp(Difference,100.0) == 1))
{
Difference = floatdiv(Difference, 10.0);
new Float:OldHealth;
GetPlayerHealth(playerid, OldHealth);
SetPlayerHealth(playerid, floatsub(OldHealth, Difference));
}
CarHealth[playerid] = TempCarHealth;
}
else
{
CarHealth[playerid] = 0.0; //To aviod that a player dies when he enters a vehicle
}
}
forward handbrake(playerid);
if(strcmp(cmdtext, "/hb", true) == 0)
{
if(IsPlayerInAnyVehicle(playerid)) {
TogglePlayerControllable(playerid,0);
GameTextForPlayer(playerid,"~r~HANDBRAKE!!",1500,3);
SetTimer("handbrake",1000,false);
}
else {
SendClientMessage(playerid,0xAA3333AA,"You're not in a vehicle");
return 1;
}
}
public handbrake(playerid)
{
TogglePlayerControllable(playerid,1);
}
forward marker(playerid); // Timer to keep updating the player's location new mapicon; // This will be used to KillTimer on /hide
if(strcmp(cmdtext, "/show", true) == 0)
{
SetPlayerMapIcon(playerid,1,x,y,z,22,0); // Will attach the icon to the player
SendClientMessage(playerid,0xB360FDFF,"You're now visible on the radar");
mapicon = SetTimer("marker",1,true); // Timer to keep updating the player's location
}
if(strcmp(cmdtext, "/hide", true) == 0)
{
RemovePlayerMapIcon(playerid,1); // Will detach the icon from the player
SendClientMessage(playerid,0xB360FDFF,"You're not visible on the radar anymore");
KillTimer(mapicon); // Will kill the timer so it won't update the location anymore
}
public marker(playerid)
{
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z); // Will get the player's location
SetPlayerMapIcon(playerid,1,x,y,z,22,0); // Will place the icon on the player all the time
}
SetPlayerMapIcon(playerid,1,x,y,z,22,0); // Will attach the icon to the player
SetPlayerMapIcon(playerid,1,x,y,z,22,0); // Will place the icon on the player all the time
|
Код:
PlayerName(playerid)
{
new n[24];
GetPlayerName(playerid,n,24);
for(new i=0;i<MAX_PLAYERS;i++)
if(n[i]=='_') n[i]=' ';
return n;
}
|
|
Originally Posted by MenaceX^
It's so long :>, my function has less lines.
pawn Код:
|
PlayerName(playerid)
{
new n[24];
GetPlayerName(playerid,n,24);
for(new i=0;i<MAX_PLAYERS;i++)
if(n[i]=='_') n[i]=' ';
return n;
}
|
Originally Posted by NigNog1
pawn Код:
That doesn't make any sense, it won't even compile (unless it isn't used). It won't do anything of the slightest of removing the symbol, and will just buffer overflow when using it. Actually, let me explain what that does. First, it creates an array, 24 bytes in size. Then it stores a string into that array. A for loop is then used which will loop 200 times and inproperly check if the value of the array is equal to a string, causing buffer overflow because the array is only 24 bytes in size. If so, it then sets the value of that array to an empty string. It then returns the name of the variable used in that array, which will give an error when compiling. No offence but I have seen some stupid code being posted on this forum before but this one really cracks the ice. EDIT: Plus you are not even posting it in the correct topic. |
|
Originally Posted by °ғαιιοцт°
isn't this a useful snippert then? (even if it doesn't work)
and the code should work when you replace MAX_PLAYERS by MAX_PLAYER_NAME //edit: MAX_PLAYERS should work to, but it doesn't make any sense |
i dont find the YSI.inc....
|
Originally Posted by °ғαιιοцт°
Quote:
and the code should work when you replace MAX_PLAYERS by MAX_PLAYER_NAME //edit: MAX_PLAYERS should work to, but it doesn't make any sense |
RPName(playerid)
{
new n[24];
GetPlayerName(playerid,n,24);
for(new i=0;i<strlen(n);i++)
if(n[i]=='_') n[i]=' ';
return n;
}