Herro[CM] |
Дата: Среда, 09.09.2015, 22:56 | Сообщение # 1
|
Бывалый
Сообщений: 425
Статус: Offline
|
Данный include позволит изменить гравитацию для конкретного игрока. Код #include <a_samp> #if defined _setgravity_included #endinput #endif #define _setgravity_included static bool:moving[MAX_PLAYERS char]; static falltime[MAX_PLAYERS]; static Float:velZ[MAX_PLAYERS]; static Float:gravity[MAX_PLAYERS]; static bool:setgravity[MAX_PLAYERS char]; SetGravity_OnPlayerConnect(playerid) { moving{playerid} = false; velZ{playerid} = 0.0; gravity[playerid] = 0.0; setgravity{playerid} = false; } SetGravity_OnPlayerUpdate(playerid) { if(setgravity{playerid} && GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) { new Float:x, Float:y, Float:z; GetPlayerVelocity(playerid, x, y, z); new anim = GetPlayerAnimationIndex(playerid); if(anim == 1130 || anim == 1132 || anim == 1195) { if(!moving{playerid} || z == 0.0) { velZ[playerid] = z; moving{playerid} = true; falltime[playerid] = GetTickCount(); } new time = GetTickCount()-falltime[playerid]; z = (gravity[playerid]*time)/1000.0; if(z > 1.17) z = 1.17; SetPlayerVelocity(playerid, x, y, velZ[playerid]-z); }else{ moving{playerid} = false; } } } stock SetPlayerGravity(playerid, Float:newgravity) { setgravity{playerid} = true; gravity[playerid] = newgravity*50.0; moving{playerid} = false; } stock ResetPlayerGravity(playerid) { setgravity{playerid} = false; gravity[playerid] = 0.0; moving{playerid} = false; }
Установка: Код #include <setgravity> - Кидаем в начало мода. SetGravity_OnPlayerConnect(playerid); - кидаем в public OnPlayerConnect(playerid) SetGravity_OnPlayerUpdate(playerid); - кидаем в public OnPlayerUpdate(playerid)
Пример: Код public OnPlayerCommandText(playerid, cmdtext[]) { if(!strcmp(cmd,"/sgravity",true)) { if(!IsPlayerAdmin(playerid)) return 1; tmp = strtok(cmdtext, idx); if(!strlen(tmp) || !isNumeric(tmp)) return SendClientMessage(playerid,CGRAY,"/sgravity [ID игрока] [gravity]"); new id = strval(tmp); if(!IsPlayerConnected(id)) return SendClientMessage(playerid,CGRAY,"Вы ввели не верный ID"); tmp = strtok(cmdtext, idx); new Float:gravity; gravity = floatstr(tmp); SetPlayerGravity(id,gravity); return 1; } return 1; }
Когда нет знания, есть мнение.
|
|
|
|
Surex |
Дата: Суббота, 02.07.2016, 14:04 | Сообщение # 2
|
Боец
Сообщений: 137
Статус: Offline
|
полезно
|
|
|
|
Плисс |
Дата: Вторник, 19.07.2016, 20:40 | Сообщение # 3
|
Боец
Сообщений: 70
Статус: Offline
|
Кросс
|
|
|
|