27.12.2012, 01:09
@PhillipS You made my day LMAO. Thanks for making me laughing as hell...
#define function%0(%1) stock %0(%1)
function ContainInvalidCharacters(string[])
{
// Add more if you need/want. (if you add new characters, you should add the quantity of characters that you put to the variable. ("19"))
new InvalidCharacters[19][] =
{
"&","$","^","?","_",".","*","#","(",")",
"[","]","{","}","=","+","-","!","@"
};
for(new checkloop; checkloop<sizeof(InvalidCharacters); checkloop++)
{
if(strfind(string, InvalidCharacters[checkloop]) != -1) return true;
}
return false;
}
public OnGameModeInit()
{
new varstring[15] = "mystringwith@";
if(ContainInvalidCharacters(varstring)) return print("- 'varstring' contains invalid characters !");
return 1;
}
[04:42:32] Filterscripts [04:42:32] --------------- [04:42:32] Loading filterscript 'gl_actions.amx'... [04:42:32] Loading filterscript 'gl_realtime.amx'... [04:42:32] Loaded 2 filterscripts. [04:42:32] - 'varstring' contains invalid characters ! [04:42:32] Number of vehicle models: 0 |
stock isValidPassword(const szPass[]) {
for(new i = 0; szPass[i] != EOS; ++i) {
switch(szPass[i]) {
case '0'..'9', 'A'..'Z', 'a'..'z':
continue;
default:
return 0;
}
}
return 1;
}
stock MoveCameraInCircelRotation(playerid,Float:winkel2, Float:x_koordinate, Float:y_koordinate, Float:z_koordinate, Float:radius1, Float:winkel)
{
PlayerCamInfo[playerid][player_degree1] =(winkel2 > 360)?(0):((winkel < 0)?(360):(PlayerCamInfo[playerid][player_degree1]));
PlayerCamInfo[playerid][player_degree2] =(winkel > 360)?(0):((winkel < 0)?(360):(PlayerCamInfo[playerid][player_degree2]));
SetPlayerCameraLookAt(playerid,x_koordinate,y_koordinate,z_koordinate);
x_koordinate += (radius1 * floatcos(winkel, degrees) * floatcos(winkel2, degrees));
y_koordinate += (radius1 * floatcos(winkel, degrees) * floatsin(winkel2, degrees));
z_koordinate += (radius1 * floatsin(winkel, degrees));
SetPlayerCameraPos(playerid,x_koordinate,y_koordinate,z_koordinate);
return 1;
}
stock SetPlayerFacingAngleToPoint(playerid,Float:X, Float:Y){
new Float: Pos[2];
GetPlayerPos(playerid, Pos[0], Pos[1], 0);
return SetPlayerFacingAngle(playerid,180.0-atan2(Pos[0]-X,Pos[1]-Y));
}
stock
Float:absoluteangle2(Float:angle)
{
while(angle < 0.0) angle += 360.0
while(angle > 360.0) angle -= 360.0;
return angle;
}
stock GetAge(string[])
{
new var0, var1, var2, Date[3], age;
sscanf(string, "p<.>iii", var0, var1, var2);
if(var0 > 31 || var0 <= 0)return 0;
if(var1 > 12 || var1 <= 0)return 0;
getdate(Date[0],Date[1],Date[2]);
if(var2 > Date[0] || var2 < 1900)return 0;
age = Date[0] - var2 - ((Date[1] < var1)? 1 : ((Date[1] == var1 && Date[2] < var0)? 1 : 0));
return age;
}
rot13(string[])
{
for(new index = 0; string[index]; index ++)
{
if ('a' <= string[index] <= 'z')
string[index] = (string[index] - 'a' + 13) % 26 + 'a';
else if ('A' <= string[index] <= 'Z')
string[index] = (string[index] - 'A' + 13) % 26 + 'A';
}
return 0;
}
// By CompuPhase
rot13(string[])
{
for (new index = 0; string[index]; index++)
if ('a' <= string[index] <= 'z')
string[index] = (string[index] - 'a' + 13) % 26 + 'a'
else if ('A' <= string[index] <= 'Z')
string[index] = (string[index] - 'A' + 13) % 26 + 'A'
}
stock GetVehiclePlayerInSeat(vehicleid, seatid) {
if (!GetVehicleModel(vehicleid)) return INVALID_VEHICLE_ID;
new
total = GetMaxPlayers()
;
for (new x; x < total; x++) {
if (IsPlayerConnected(x)) {
if (IsPlayerInAnyVehicle(x) && GetPlayerVehicleSeat(x) == seatid) {
return x; //Thanks ****** for making me notice this. (player id 0 issue)
break;
}
}
}
return INVALID_PLAYER_ID; //Thanks Slice
}
To be honest, I can't see the error, when x is declared its value should be 0, or not?
EDIT: Ohh, I'm so stup*d, I just saw that. PD: I'm going to test it right now. |
If it were player 0 in that seat, it would return 0, saying that the seat is actually empty.
Your signature is also very immature. |
stock SecToMin(sec) {
return printf("%02d:%02d", (sec/60), sec % 60);
}
stock MsToMin (sec) {
return printf("%02d:%02d:%02d", ((sec / (1000*60)) % 60), (sec / 1000) % 60,sec %1000);
}
Someone suggested this for SA-MP 0.3x, so I tried to make it:
pawn Код:
x -> player's id who is seated on the seatid. INVALID_VEHICLE_ID -> the vehicle doesn't exist. INVALID_PLAYER_ID -> the seatid is empty. PD: I didn't test it, but I guess it should work. Best regards! EDIT: Tested. |
Slice used to have a very good website where you could watch macros get expanded slowly to study them, but sadly it seems to be down at the minute. It was VERY useful for looking at macros like this.
|
"|||" is used because it can never appear normally in valid code, so macros can scan for it to find the end of a block of text. Another one I like to use is "Ј" because it's on my keyboard (being British), but I don't tend to release scripts with it due to possible character set issues.
|
stock getName(playerid)
{
new sNick_[MAX_PLAYER_NAME];
GetPlayerName(playerid, sNick_, MAX_PLAYER_NAME);
for(new iX__ = (0); iX__ < strlen(sNick_); ++ iX__) if(sNick_[iX__] == '_') sNick_[iX__] = (32);
return format(sNick_, MAX_PLAYER_NAME, "%s", sNick_), (sNick_);
}
new string[64];
format(string, (sizeof string), "My name is: %s", getName(playerid));
SendClientMessage(playerid, -1, string);
stock getName(playerid)
{
new pos = -1, name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
while ((pos = strfind(name, "_", true)) != -1)
{
name[pos] = ' ';
}
return name;
}