Wysłany: 2015-11-17, 20:29
PingwinekPlus
Uczeń Lua
Wiek: 35 Na forum: 3864 dni Posty: 79
Nick w MP: Offensywny.
Piwa : 396
Witam to jest kod kt?ry napisa?em na spray kt?ry zmienia kolor auta lecz co? nie dzia?a nie wiem dok?adnie co mo?e kto? sprawdzi? ten kod i powiedzie? co mo?e by? nie tak ?
Kod: #include <a_samp>
new Firehold[MAX_PLAYERS];
stock Float:GetDistanceBetweenPoints(Float:X, Float:Y, Float:Z, Float:PointX, Float:PointY, Float:PointZ)
{
new Float:Distance;
Distance = floatabs(floatsub(X, PointX)) + floatabs(floatsub(Y, PointY)) + floatabs(floatsub(Z, PointZ));
return Distance;
}
stock GetNearestVehicle(playerid, Float:Distance = 1000.0)
{
Distance = floatabs(Distance);
if(Distance == 0.0) Distance = 1000.0;
new Float:X[2], Float:Y[2], Float:Z[2];
new Float:NearestPos = Distance;
new NearestVehicle = INVALID_VEHICLE_ID;
GetPlayerPos(playerid, X[0], Y[0], Z[0]);
for(new i; i<MAX_VEHICLES; i++)
{
if(!IsVehicleStreamedIn(i, playerid) || i == GetPlayerVehicleID(playerid)) continue;
GetVehiclePos(i, X[1], Y[1], Z[1]);
if(NearestPos > GetDistanceBetweenPoints(X[0], Y[0], Z[0], X[1], Y[1], Z[1])) NearestPos = GetDistanceBetweenPoints(X[0], Y[0], Z[0], X[1], Y[1], Z[1]), NearestVehicle = i;
}
if(NearestPos < Distance) return NearestVehicle;
return INVALID_VEHICLE_ID;
}
forward ResprayTimer(playerid,vehicleid);
public OnPlayerKeyStateChange(playerid,newkeys,oldkeys){
if(newkeys & KEY_FIRE &&(GetPlayerWeapon(playerid) == 41 && !IsPlayerInAnyVehicle(playerid))){
new nearveh=GetNearestVehicle(playerid,5);
if(IsPlayerFacingVehicle(playerid,nearveh)){
SetTimerEx("ResprayTimer",3000,0,"ii",playerid,GetNearestVehicle(playerid,5));
Firehold[playerid] = 1;
}
}
if(oldkeys & KEY_FIRE && (Firehold[playerid] == 1)) Firehold[playerid] = 0;
return 1;
}
public ResprayTimer(playerid,vehicleid){
if(GetPlayerWeapon(playerid) == 41 && GetNearestVehicle(playerid,8) == vehicleid && Firehold[playerid] == 1){
if(IsPlayerFacingVehicle(playerid,vehicleid)){
ChangeVehicleColor(GetNearestVehicle(playerid,8),random(127),random(127));
RepairVehicle(GetNearestVehicle(playerid,8));
GameTextForPlayer(playerid,"~g~Respray sucessfull",3000,4);
}
}
return 1;
}
public OnPlayerCommandText(playerid,cmdtext[]){
if(strcmp("/spray",cmdtext,true) == 0){
GivePlayerWeapon(playerid,41,50000);
return 1;
}
return 0;
}
stock IsPlayerFacingVehicle(playerid,vehicleid)
{
new Float:pX,Float:pY,Float:pZ,Float:X,Float:Y,Float:Z,Float:ang;
if(!IsPlayerConnected(playerid)) return 0;
GetVehiclePos(vehicleid, X, Y, Z);
GetPlayerPos(playerid, pX, pY, pZ);
if( Y > pY ) ang = (-acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
else if( Y < pY && X < pX ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 450.0);
else if( Y < pY ) ang = (acos((X - pX) / floatsqroot((X - pX)*(X - pX) + (Y - pY)*(Y - pY))) - 90.0);
if(X > pX) ang = (floatabs(floatabs(ang) + 180.0));
else ang = (floatabs(ang) - 180.0);
new Float:russia;
GetPlayerFacingAngle(playerid,russia);
if(ang-russia<-130 || ang-russia>130) return 0;
else return 1;
}
Wysłany: 2015-11-17, 20:44
Jacob.luadev
Wiek: 32 Na forum: 4428 dni Posty: 20
Nick w MP: Jacob.luadev
Piwa : 4
To jest skrypt napisany w pawno. W mta piszemy w LUA, pewnie dlatego
Wysłany: 2015-11-17, 21:58
ToxiC.
Wiek: 28 Na forum: 5246 dni Posty: 3792
Piwa : 8590
"PingwinekPlus" napisał/a : to jest kod kt?ry napisa?em
Ta.. napisa?e?.
"PingwinekPlus" napisał/a :
Co? du?o m?wi, w uj... We? cz?owieku jak piszesz temat to napisz co nie dzia?a, bo nikt nie b?dzie sprawdza? dla Ciebie specjalnie kodu, ?eby Ci p??niej naprawi?. A jak Ci si? nie chce pisa? co nie dzia?a to tu nie pisz i nie k*** ludzi ?e si? tak brzydko wyra?e.
[ Komentarz dodany przez: DestroY : 2015-11-18, 10:34 ]
On to tworzy? w PAWN z my?l? o MTA, wi?c by? mo?e wszystko by dzia?a?o, tylko ?e nie ten multiplayer.
Tagi: spray :: mta
Anonymous
Na forum: 245 dni
Posty: 1
Anonymous Koniecznie zajrzyj na: