15.04.2009, 08:41
Quote:
Originally Posted by Nubotron
QuatToEuler(Float:qx, Float:qy, Float:qz, Float:qw, &Float:ex, &Float:ey, &Float:ez, bool:normalize = false)
edit: bug, work 50%.. |
Originally Posted by Nubotron
QuatToEuler(Float:qx, Float:qy, Float:qz, Float:qw, &Float:ex, &Float:ey, &Float:ez, bool:normalize = false)
edit: bug, work 50%.. |
Originally Posted by MoroJr™
Quote:
|
Originally Posted by zozo
Re-edited, i was wrong, it working 100% i think!
|
Originally Posted by 0rb
Quote:
|
stock PlayerToPlayer(playerid, destid, Float:radius)
{
if(!IsPlayerConnected(playerid)) return -1; // Checks if player is connected
{
new Float:X, Float:Y, Float:Z; // Base x, y, z values
new Float:px, Float:py, Float:pz; //px, py, pz used to express
GetPlayerPos(playerid, X, Y, Z); //
GetPlayerPos(destid, px, py, pz); //
X = floatsub(X, px);
Y = floatsub(Y, py);
Z = floatsub(Z, pz);
if( ( radius > X && X > -radius ) &&
( radius > Y && Y > -radius ) &&
( radius > Z && Z > -radius ) ) return 1;
}
return 0;
}
stock TurnPlayerFaceToPlayer(playerid, facingtoid)
{
new Float:angle;
new Float:misc = 5.0;
new Float:x, Float:y, Float:z;
new Float:ix, Float:iy, Float:iz;
GetPlayerPos(facingtoid, x, y, z);
GetPlayerPos(playerid, ix, iy, iz);
angle = 180.0-atan2(ix-x,iy-y);
angle += misc;
misc *= -1;
SetPlayerFacingAngle(playerid, angle+misc);
}
Originally Posted by lrZ^ aka LarzI
Maybe add a SetPlayerCameraLookAt too ?
|
stock PlayerVehicleToPoint(playerid,Float:x,Float:y,Float:z)
{
if(IsPlayerConnected(playerid))
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
tempposx = (oldposx -x);
tempposy = (oldposy -y);
tempposz = (oldposz -z);
if(IsPlayerInAnyVehicle(playerid))
{
GetVehiclePos(GetPlayerVehicleID(playerid), oldposx, oldposy, oldposz);
if (((tempposx < 3) && (tempposx > -3)) && ((tempposy < 3) && (tempposy > -3)) && ((tempposz < 3) && (tempposz > -3)))
{
return 1;
}
} else {
if (((tempposx < 3) && (tempposx > -3)) && ((tempposy < 3) && (tempposy > -3)) && ((tempposz < 3) && (tempposz > -3)))
{
return 1;
}
}
}
return false;
}
//Top of script
forward timer1();
//OnGameModeInit
SetTimer("timer1", 1000, 1); //Every second
CreatePickup(1550,23,2302.2800,1387.9668,42.4453); //Example pickup
//Anywhere
public timer1()
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(PlayerVehicleToPoint(i,2302.2800,1387.9668,42.4453)) //Is the same coordinates of the example pickup
{
new vehid = GetPlayerVehicleID(i);
SetVehiclePos(vehid,5555,5555,5555);
PutPlayerInVehicle(i,vehid,0);
}
}
}
return 1;
}
stock GetFileDataFromSelectLine(filename[], line, result[]) { new File:FileHandle; new LineData[1024 char]; new LoadCount = 0; if(!fexist(filename)) { printf("Could not open \"%s\" ",filename); return false; } FileHandle = fopen(filename, io_read); while(fread(FileHandle, LineData)) { if(LoadCount == (line - 1)) { if(LineData[0] == 0) { continue; } if((LineData[strlen(LineData) - 1] == '\n') || (LineData[strlen(LineData) - 1] == '\r')) { LineData[strlen(LineData) - 1] = 0; if((LineData[strlen(LineData) - 2] == '\n') || (LineData[strlen(LineData) - 2] == '\r')) { LineData[strlen(LineData) - 2] = 0; } if(LineData[0] == 0) { continue; } } format(result, sizeof(LineData), "%s", LineData); fclose(FileHandle); return true; } LoadCount += 1; } fclose(FileHandle); return false; }
GetFileDataFromSelectLine("settings.txt", 4, str)
stock fclear(File[])
{
new File:FileC;
FileC = fopen(File, io_write);
fwrite(File, " ");
fclose(File);
return 1;
}
Originally Posted by ► James_Alex
Clear A File
pawn Код:
|
fclear( file[] )
{
if ( file[ 0 ] && fexists( file ) )
{
fremove( file );
new File: f = fopen( file, io_write );
if ( f )
{
fclose( f );
return true;
}
}
return false;
}
if ( fclear( "some_file.txt" ) ) print( "'some_file.txt' was cleared" );
else print( "failed to clear 'some_file.txt'" );
public Float:GetDistanceBetweenPlayers(p1,p2)
{
new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
if(!IsPlayerConnected(p1) || !IsPlayerConnected(p2))
{
return -1.00;
}
GetPlayerPos(p1,x1,y1,z1);
GetPlayerPos(p2,x2,y2,z2);
return floatsqroot((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)+(z2-z1)*(z2-z1));
}
return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
floatsqroot((x2-=x1)*x2 + (y2-=y1)*y2 + (z2-=z1)*z2);
Originally Posted by paytas
pawn Код:
|
stock TruncateTable(table[])
{
format(string,sizeof(string),"TRUNCATE TABLE `%s`",table);
samp_mysql_real_escape_string(table,table);
samp_mysql_query(string);
return 1;
}
stock query(string[])
{
if(samp_mysql_ping>=1)
{
samp_mysql_connect("host","user","password");
samp_mysql_select_db("database");
print("Attempting to re-connect due to losing connection.");
}
else
{
samp_mysql_real_escape_string(string,string); // To escape invalid characters.
samp_mysql_query(string);
}
}
Originally Posted by ssǝן‾ʎ
That code makes no sense and frankly won't work! You can't escape ALL of a query else it won't work - those characters are special for a reason. Also, I don't understand why you check for "INSERT", "SELECT" or "UPDATE" and assume they've lost connection if they didn't enter one of them, what if they've lost connection but did enter one of them? Or what if they're doing a "DROP" or "DELETE" or one of the many other types of query? If it was that simple to make queries secure, don't you think it would be built into SQL?
Also, why MySQL and not SQLite, the default official database? |