13.06.2010, 05:37
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(IsPlayerFreezed(playerid))
{
ClearAnimation(playerid);
Freeze(playerid, 1);
}
return 1;
}
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(IsPlayerFreezed(playerid))
{
ClearAnimation(playerid);
Freeze(playerid, 1);
}
return 1;
}
Originally Posted by Fro1sha
pawn Код:
|
Originally Posted by Romanius
Это же свитч лучше делать все по порядку
|
#define PointToPoint3D2(%1,%2,%3,%4,%5,%6) floatsqroot(floatadd(floatadd(floatmul(floatsub(%1,%4),floatsub(%1,%4)),floatmul(floatsub(%2,%5),floatsub(%2,%5))),floatmul(floatsub(%3,%6),floatsub(%3,%6))))
#define PointToPoint3D4(%1,%2,%3,%4,%5,%6) floatsqroot((%1-%4)*(%1-%4)+(%2-%5)*(%2-%5)+(%3-%6)*(%3-%6))
stock Float:PointToPoint3D3( Float:X1, Float:Y1, Float:Z1, Float:X2, Float:Y2, Float:Z2 )
{
new
Float:X,
Float:Y,
Float:Z;
X = floatsub( X1, X2 );
Y = floatsub( Y1, Y2 );
Z = floatsub( Z1, Z2 );
X = floatmul( X, X );
Y = floatmul( Y, Y );
Z = floatmul( Z, Z );
return floatsqroot( floatadd( floatadd( X, Y ), Z ) );
}
main
{
new i, tick = GetTickCount(), Float:point;
while ( i < 10000000)
{
point = PointToPoint3D3(10.0, 20.0, 30.0, 40.0, 50.0, 60.0);
i++;
}
printf("1 Time %d | %f", GetTickCount() - tick, point);
i = 0;
tick = GetTickCount();
while ( i < 10000000)
{
point = PointToPoint3D2(10.0, 20.0, 30.0, 40.0, 50.0, 60.0);
i++;
}
printf("2 Time %d | %f", GetTickCount() - tick, point);
i = 0;
tick = GetTickCount();
while ( i < 10000000)
{
point = PointToPoint3D4(10.0, 20.0, 30.0, 40.0, 50.0, 60.0);
i++;
}
printf("3 Time %d | %f", GetTickCount() - tick, point);
}
1 Time 6282 | 51.961524 2 Time 6433 | 51.961524 3 Time 7436 | 51.961524 |
//------------------------------------------------------------------------------------------------------ public cmdGetArgInt(args[], &idx, &intvalue) { new i = 0; // skip spaces while (args[idx] && (args[idx] <= ' ')) idx++; // copy value while (args[idx] && (args[idx] > ' ')) { tmp[i] = args[idx]; idx++; i++; // Слишком большое число! if (i >= sizeof(tmp)) return 0; } if (i == 0) return 0; tmp[i] = EOS; intvalue = strval(tmp); if (intvalue == 0) { if (args[idx - 1] == '0' && args[idx] == EOS) return 1; else return 0; } return 1; } //------------------------------------------------------------------------------------------------------ public cmdGetArgHex(args[], &idx, &hexvalue) { new digits = 0; // skip spaces while (args[idx] && (args[idx] <= ' ')) idx++; // check hex format 0x if ((args[idx] != EOS) && (args[idx + 1] != EOS) && (args[idx] == '0') && ((args[idx + 1] == 'x') || (args[idx + 1] == 'X'))) {} else return 0; idx += 2; hexvalue = 0; // copy value while (args[idx] && (args[idx] > ' ')) { switch (args[idx]) { case '0' .. '9': { hexvalue = (hexvalue << 4) | (args[idx] - '0'); } case 'a' .. 'f': { hexvalue = (hexvalue << 4) | (args[idx] - ('a' - 10)); } case 'A' .. 'F': { hexvalue = (hexvalue << 4) | (args[idx] - ('A' - 10)); } default: { return 0; } } idx++; digits++; if (digits > 8) return 0; } //if (hexvalue == 0 && digits == 0) return 0; if (digits != 8) return 0; return 1; } //------------------------------------------------------------------------------------------------------ public cmdGetArgPla(args[], &idx, &pid) { new i = 0; // skip spaces while (args[idx] && (args[idx] <= ' ')) idx++; // copy value while (args[idx] && (args[idx] > ' ')) { tmp[i] = args[idx]; idx++; i++; // Слишком большое число! if (i >= sizeof(tmp)) return 0; } if (i == 0) return 0; tmp[i] = EOS; pid = ReturnUser(tmp); if (pid == INVALID_PLAYER_ID) return 0; return 1; } //------------------------------------------------------------------------------------------------------ public cmdGetArgFlo(args[], &idx, &Float:floatvalue) { new i = 0; // skip spaces while (args[idx] && (args[idx] <= ' ')) idx++; // copy value while (args[idx] && (args[idx] > ' ')) { tmp[i] = args[idx]; idx++; i++; // Слишком большое число! if (i >= sizeof(tmp)) return 0; } if (i == 0) return 0; tmp[i] = EOS; floatvalue = floatstr(tmp); return 1; } //------------------------------------------------------------------------------------------------------ public cmdGetArgStr(args[], &idx, retstr[]) { new i = 0; // skip spaces while (args[idx] && (args[idx] <= ' ')) idx++; // copy value while (args[idx] && (args[idx] > ' ')) { retstr[i] = args[idx]; idx++; i++; // Слишком большая строка if (i >= 32) return 0; } if (i == 0) return 0; retstr[i] = EOS; return 1; } //------------------------------------------------------------------------------------------------------ public cmdGetArgZtr(args[], &idx) { // skip spaces while (args[idx] && (args[idx] <= ' ')) idx++; if (args[idx] == EOS) return 0; return 1; } //------------------------------------------------------------------------------------------------------
//////////////////////////////////////////////////////////////////////////////////////////// case 40: { new Float:r = 7.0, Float:x, Float:y, Float:z; cmdGetArgFlo(args, idx, r); GetPlayerPos(gpid, x, y, z); DisablePlayerCheckpoint(gpid); SetPlayerCheckpoint(gpid, x, y, z, r); format(string, sizeof(string), "SetPlayerCheckpoint(%d, %.1f, %.1f, %.1f, %.1f)", gpid, x, y, z, r); SendClientMessage(playerid, 0xCC55FFFF, string); } ////////////////////////////////////////////////////////////////////////////////////////////
if (!cmdGetArgPla(args, idx, gpid)) { SendClientMessage(playerid, COLOR_WRONG_ARG, cs_ThisPlayerIsNotOnline); return 1; }
//////////////////////////////////////////////////////////////////////////////////////////// case 31: { new veh; new Float:x = 0, Float:y = 0, Float:z = 0; if (!cmdGetArgInt(args, idx, veh) || !GetVehicleModel(veh)) { SendClientMessageRus(playerid, COLOR_WRONG_ARG, " Введите ид тачки."); return 1; } cmdGetArgFlo(args, idx, x); cmdGetArgFlo(args, idx, y); cmdGetArgFlo(args, idx, z); SetVehicleVelocity(veh, x, y, z); format(string, sizeof(string), " SetVehicleVelocity(%d, %.2f, %.2f, %.2f)", veh, x, y, z); SendClientMessage(playerid, 0x7FFF30FF, string); } ////////////////////////////////////////////////////////////////////////////////////////////
//----------------------------------------------------------------------------------------------------- // Шаблон редакторов !!! #define Case0(%0) case %0: if ((res = editor_fn(id, %0)) == 0) #define Case1(%0,%1) case %0: if ((res = editor_fn(id, %0, %1)) == 0) #define Case2(%0,%1,%2) case %0: if ((res = editor_fn(id, %0, %1, %2)) == 0) #define Case3(%0,%1,%2,%3) case %0: if ((res = editor_fn(id, %0, %1, %2, %3)) == 0) #define Case4(%0,%1,%2,%3,%4) case %0: if ((res = editor_fn(id, %0, %1, %2, %3, %4)) == 0) #define Case5(%0,%1,%2,%3,%4,%5) case %0: if ((res = editor_fn(id, %0, %1, %2, %3, %4, %5)) == 0) public OnCmd_Adm_TpEdit(pid, tid, cmd[], args[]) // tpedit { #define editor_fn teleportEdit #define en cs_NameEditorTp new ploc = gPI[pid][pLoc], idx = 0, cmdid, id = tid, Float:f1 = 0.0, Float:f2 = 0.0, res = -100, t1 = 0, t2 = 0; for (cmdid = 0; cmdid < tpeditor_CmdCount; cmdid++) { if ( strcmp(cmd, cTpEditorCmd [ cmdid ] ) == 0) break; } cmdGetArgInt(args, idx, t1); cmdGetArgInt(args, idx, t2); idx = 0; cmdGetArgFlo(args, idx, f1); cmdGetArgFlo(args, idx, f2); GetPlayerPos(pid, fpos[0], fpos[1], fpos[2]); GetPlayerFacingAngle(pid, fpos[3]); format(string, sizeof(string), " cmdid = %d", cmdid); SendClientMessageRus(pid, COLOR_TP_EDIT, string); switch (cmdid) { Case4(tpeditor_P0, fpos[0], fpos[1], fpos[2], ploc) { format(string, sizeof(string), " %s: ID: %d, p0 = (%.1f, %.1f, %.1f), loc: %d.", en, id, fpos[0], fpos[1], fpos[2], ploc); } Case5(tpeditor_P1, fpos[0], fpos[1], fpos[2], fpos[3], ploc) { format(string, sizeof(string), " %s: ID: %d, p1 = (%.1f, %.1f, %.1f, %.1f), loc: %d.", en, id, fpos[0], fpos[1], fpos[2], fpos[3], ploc); } Case0(tpeditor_SaveAll) { format(string, sizeof(string), " %s: Телепорты сохранены в файл: %s.", en, FILENAME_TELEPORTS); } Case0(tpeditor_Update) { format(string, sizeof(string), " %s: ID: %d, Обновлен.", en, id); } Case0(tpeditor_TogSilent) { format(string, sizeof(string), " %s: ID: %d, (FLAG) Режим тихой телепортации: %s.", en, id, cOnOff[res]); } Case0(tpeditor_TogVis) { format(string, sizeof(string), " %s: ID: %d, (FLAG) Видимость: %s.", en, id, cOnOff[res]); } Case0(tpeditor_TogVeh) { format(string, sizeof(string), " %s: ID: %d, (FLAG) Разрешить телепорт ТС: %s.", en, id, cOnOff[res]); } Case0(tpeditor_TogEdit) { format(string, sizeof(string), " %s: ID: %d, (FLAG) Редактирование: %s.", en, id, cOnOff[res]); } Case0(tpeditor_TogEnabled) { format(string, sizeof(string), " %s: ID: %d, (FLAG) Состояние: %s.", en, id, cOnOff[res]); } Case0(tpeditor_TogObjPickup) { format(string, sizeof(string), " %s: ID: %d, Тип объекта телепорта сменен. Пикап: %s.", en, id, cYesNo[res]); } Case1(tpeditor_GotoP0, pid) { format(string, sizeof(string), " %s: ID: %d, Телепорт к входу.", en, id); } Case1(tpeditor_GotoP1, pid) { format(string, sizeof(string), " %s: ID: %d, Телепорт к выходу.", en, id); } Case0(tpeditor_Delete) { format(string, sizeof(string), " %s: ID: %d, Удален.", en, id); } Case1(tpeditor_Rad, f1) { format(string, sizeof(string), " %s: ID: %d, Радиус: %d.", en, id, f1); } Case1(tpeditor_Model, t1) { format(string, sizeof(string), " %s: ID: %d, Модель: %d.", en, id, t1); } Case1(tpeditor_Info, pid) { return 1; } default: { format(string, sizeof(string), " %s: Неправильная команда!", en); SendClientMessageRus(pid, COLOR_WRONG_ARG, string); return 1; } } if (res >= 0) { SendClientMessageRus(pid, COLOR_TP_EDIT, string); return 1; } else { switch (res) { case tpeditor_err_not_editable: { format(string, sizeof(string), " %s: ID: %d, Редактирование запрещено", en, id); } case tpeditor_err_invalid_rad: { format(string, sizeof(string), " %s: ID: %d, Введен недопустимый радиус", en, id); } case tpeditor_err_invalid_p0: { format(string, sizeof(string), " %s: ID: %d, Возник конфликт зон! Внимание: ставьте телепорты подальше друг от друга и от сублокаций!", en, id); } case tpeditor_err_invalid_tpid: { //format(string, sizeof(string), " Редактор телепортов: ID: %d, Введите корректный идентификатор телепорта.", id); format(string, sizeof(string), " Номер телепорта: [%d, %d].", 0, MAX_TELEPORTS - 1); } default: { format(string, sizeof(string), " %s: ID: %d, Ошибка: %d", en, id, res); } } SendClientMessageRus(pid, COLOR_WRONG_ARG, string); } #undef editor_fn #undef en return 1; }
static _PackPlayerAccInfo(pid) { new tut = 1 /*GetPlayerFlag1(pid, f1_Tutorial)*/, sex = gPA[pid][paSex], origin = gPA[pid][paOrigin], day = gPA[pid][paBirthDate][0], mon = gPA[pid][paBirthDate][1], year = gPA[pid][paBirthDate][2], reg = 1, res; res = ((sex & 1) | ((tut & 1) << 1) | ((reg & 1) << 2) | ((origin & 15) << 3) | ((day & 31) << 7) | ((mon & 15) << 12) | ((year & 2047) << 16)); return res; } static _UnPackPlayerAccInfo(pid, data) { new tut, sex, origin, day, mon, year, reg; sex = (data & 1); tut = ((data >> 1) & 1); reg = ((data >> 2) & 1); origin = ((data >> 3) & 15); day = ((data >> 7) & 31); mon = ((data >> 12) & 15); year = ((data >> 16) & 2047); gPA[pid][paSex] = sex; gPA[pid][paOrigin] = origin; gPA[pid][paBirthDate][0] = day; gPA[pid][paBirthDate][1] = mon; gPA[pid][paBirthDate][2] = year; //if (tut) // SetPlayerFlag1(pid, f1_Tutorial); //else // ResetPlayerFlag1(pid, f1_Tutorial); return 1; }
привел код-идею а не конкретный код =) кому надо тот разберется ибо это не для новичков)
|
stock mysql_install( file_name[] = "" ) {
if( !file_name[0] ) return 0
new tmp[0xff], string[0xff*8]
new File:f = fopen( file_name )
printf( "[sql] --- Install `%s`:", file_name )
while( fread( f, tmp ) ) {
format( string, sizeof string, "%s%s", string, tmp )
}
fclose( f )
samp_mysql_query( string )
print( "[sql] --- Installation complete..." )
return 1
}
stock mysql_install( file_name[] = "" )
{
if( !file_name[0] ) return 0;
new File:f = fopen( file_name );
if ( f ) // Проверка на открытие файла
{
new tmp[0xff], string[0xff*8];
printf( "[sql] --- Install `%s`:", file_name );
while( fread( f, tmp ) ) format( string, sizeof string, "%s%s", string, tmp );
fclose( f );
samp_mysql_query( string );
print( "[sql] --- Installation complete..." );
return 1;
}
return 0;
}
#pragma semicolon 0
1. new a, b, c, d
2. return 0
3. print("lol")
Но буквы можно сделать, только не все) Косые линии нельзя рисовать ганг зонами.
|