Szerző Téma: Script HIBA  (Megtekintve 1688 alkalommal)

Script HIBA
« Dátum: 2012. Január 14. - 15:43:15 »
0 Show voters
Üdv itt van ez a script de hibás kéne nekem egy kis segítség.
[pawn]if(IsPlayerInRangeOfPoint(playerid,3.0,2123.0464,44.5196,26.4302) )
{
       if(IsPlayerInAnyVehicle(playerid))
{
      SetPlayerSpeedCap(playerid,0.2);
   }
}[/pawn]
És ezek a hibák vannak benne:
 
C:\\Users\\Ati\\Desktop\\MOJE DOKUMENTY\\GTA San Andreas\\Personal\\Dunra RPG szerver\\gamemodes\\dunrarpg.pwn(54264) : error 017: undefined symbol \"SetPlayerSpeedCap\"
C:\\Users\\Ati\\Desktop\\MOJE DOKUMENTY\\GTA San Andreas\\Personal\\Dunra RPG szerver\\gamemodes\\dunrarpg.pwn(54271) : error 017: undefined symbol \"SetPlayerSpeedCap\"

 
Elõre is köszönöm.

Nem elérhető IXT

  • 2502
  • Steph Curry
    • Profil megtekintése
Script HIBA
« Válasz #1 Dátum: 2012. Január 14. - 15:44:20 »
0 Show voters
defináld
 
undefined symbol \"SetPlayerSpeedCap\"
undefined symbol \"SetPlayerSpeedCap\"

Script HIBA
« Válasz #2 Dátum: 2012. Január 14. - 16:07:33 »
0 Show voters
Idézetet írta: IXT date=1326552260\" data-ipsquote-contentapp=\"forums\" data-ipsquote-contenttype=\"forums\" data-ipsquote-contentid=\"15557\" data-ipsquote-contentclass=\"forums_Topic
defináld
 
undefined symbol \"SetPlayerSpeedCap\"
undefined symbol \"SetPlayerSpeedCap\"

 

Ennyit én is tudok de hogyan kell ez itt a kérdés.

dexi

  • Vendég
Script HIBA
« Válasz #3 Dátum: 2012. Január 14. - 16:24:02 »
0 Show voters
stock SetPlayerSpeedCap(playerid, value)
{
        // Funkció
}

Script HIBA
« Válasz #4 Dátum: 2012. Január 14. - 16:24:36 »
0 Show voters
Bunkó válasz szal ne sértõdj meg de ez az igazság, és a segítség egyben.
Ahonnan kimásoltad a kódot, abban keresd ezt a funkciót \"SetPlayerSpeedCap\", mivel nem alap  SA-MP native funkció vagy az alap include fájlokban szereplõ eljárás, hanem valaki megírta.
Ezért keresgélj a szkriptben ahonnan szedted, lehetséges hogy egy include .inc fájlban találod meg.
Másik lehetõség hogy megírod:
[pawn]stock SetPlayerSpeedCap(playerid, Float:bla)
{
    printf(\"Tanulgatok szkriptelni: playerid: %d | Float: %f\", playerid, bla);
    return 1;
}[/pawn]
Elnézést kérek, de másképp nem tudtam leírni. :D :D
Edit: javítva a print printf-re. Kösz az észrevételt Fl0rian.
« Utoljára szerkesztve: 2012. Január 14. - 16:54:16 írta ɐʞzssǝlosz »

dexi

  • Vendég
Script HIBA
« Válasz #5 Dátum: 2012. Január 14. - 16:42:44 »
0 Show voters
Zsolesszka, nem volt bunkó válasz amit írtál csak az igazság :D.
Am azthiszem nem print hanem printf.

Script HIBA
« Válasz #6 Dátum: 2012. Január 14. - 17:13:09 »
0 Show voters
Idézetet írta: ɐʞzssǝlosz date=1326554676\" data-ipsquote-contentapp=\"forums\" data-ipsquote-contenttype=\"forums\" data-ipsquote-contentid=\"15557\" data-ipsquote-contentclass=\"forums_Topic
Bunkó válasz szal ne sértõdj meg de ez az igazság, és a segítség egyben.
Ahonnan kimásoltad a kódot, abban keresd ezt a funkciót \"SetPlayerSpeedCap\", mivel nem alap  SA-MP native funkció vagy az alap include fájlokban szereplõ eljárás, hanem valaki megírta.
Ezért keresgélj a szkriptben ahonnan szedted, lehetséges hogy egy include .inc fájlban találod meg.
Másik lehetõség hogy megírod:
[pawn]stock SetPlayerSpeedCap(playerid, Float:bla)
{
    printf(\"Tanulgatok szkriptelni: playerid: %d | Float: %f\", playerid, bla);
    return 1;
}[/pawn]
Elnézést kérek, de másképp nem tudtam leírni. :D :D
Edit: javítva a print printf-re. Kösz az észrevételt Fl0rian.
 
Zsoleszka ha valami kész scriptbõl szedtem volna ezt akkor megtaláltam volna a hibát. De ezt az egyik topicban írták, de csak ezt a kódot semmi egyéb ott nem volt csak maga a script, de a definiálása az nem volt leírva ha akarod adok linket is rá: http://sampforum.hu/index.php?topic=18966.0
És én nem vagyok ennyire profi csak tanuló szal nem tudom megírni ezért kérem a segítségeteket

dexi

  • Vendég
Script HIBA
« Válasz #7 Dátum: 2012. Január 14. - 17:23:54 »
0 Show voters

Script HIBA
« Válasz #8 Dátum: 2012. Január 14. - 20:25:39 »
0 Show voters
Igen csak nekem valamiért errort ír a linkre.....nem tudsz másik linket én már kerestem de valamiért nem sok sikerrel, vagy ha neked megvan akkor nem tudnád nekem valahova feltölteni.

Script HIBA
« Válasz #9 Dátum: 2012. Január 14. - 23:22:52 »
0 Show voters
A letöltési link valóban rossz a hozzászólásokban szokás ilyenkor keresgélni ezt találtam:
http://forum.sa-mp.com/showpost.php?p=1253404&postcount=27
És ezt:
http://webcache.googleusercontent.com/search?q=cache:v1dyNP6ivIIJ:realcop228.com/sampreleases/notmine/speedcap.inc+http://realcop228.com/sampreleases/&cd=3&hl=hu&ct=clnk&gl=hu
 
/*
Vehicle speed cap filterscript.
-----------
This makes it possible to limit the maxspeed of vehicles; there are, however, a few things to consider.
* This will not work well on people with high pings.
* This works best with lower server rates.
* Driving at the speed limit will cause the handling to be different; however, if
  used for roleplay, driving real-life like shouldn\'t be an issue with this at all!
How do I get started with this?
First off,
Try it on to see if it works. Load the filterscript, go ingame, and log in with /rcon login.
Now, use the testing command /myspeedcap to see if it works. An example of a value that feels like 50 km/h is 0.3.
So, simply:
/myspeedcap 0.3
Put the macros below in your other scripts and do this for example:
SetPlayerSpeedCap( playerid, 0.3 );
Another example that disables speed cap only for the NRG:
public OnPlayerEnterVehicle( playerid, vehicleid, ispassenger )
{
   new modelid = GetVehicleModel( vehicleid );
   if ( modelid == 522 ) // 522 - NRG-500
      SetPlayerSpeedCap( playerid, 0.4 );
   else
      DisablePlayerSpeedCap( playerid );
}
Put this in other scripts so they can change the speed cap easily.
#define SetPlayerSpeedCap(%0,%1) CallRemoteFunction( \"SetPlayerSpeedCap\", \"if\", %0, %1 )
#define DisablePlayerSpeedCap(%0) CallRemoteFunction( \"DisablePlayerSpeedCap\", \"i\", %0 )
Author: Slice
*/
#include <a_samp>
#include <YSI\\y_hooks>
forward SetPlayerSpeedCap( playerid, Float:value );
forward DisablePlayerSpeedCap( playerid );
new
Float:g_fSpeedCap[ MAX_PLAYERS ] = { 0.0, ... }
;
hook OnPlayerUpdate(playerid)
{
static
s_iVehicle
;
if ( g_fSpeedCap[ playerid ] != 0.0 && GetPlayerState( playerid ) == PLAYER_STATE_DRIVER )
{
s_iVehicle = GetPlayerVehicleID( playerid );
if ( s_iVehicle )
{
   static
      Float:s_fX,
      Float:s_fY,
      Float:s_fZ,
      Float:s_fVX,
      Float:s_fVY,
      Float:s_fVZ
   ;
   GetVehiclePos( s_iVehicle, s_fX, s_fY, s_fZ );
   GetVehicleVelocity( s_iVehicle, s_fVX, s_fVY, s_fVZ );
   if ( !IsPlayerInRangeOfPoint( playerid, g_fSpeedCap[ playerid ] + 0.05, s_fX + s_fVX, s_fY + s_fVY, s_fZ + s_fVZ ) )
   {
      static
         Float:s_fLength
      ;
      s_fLength = floatsqroot( ( s_fVX * s_fVX ) + ( s_fVY * s_fVY ) + ( s_fVZ * s_fVZ ) );
      s_fVX = ( s_fVX / s_fLength ) * g_fSpeedCap[ playerid ];
      s_fVY = ( s_fVY / s_fLength ) * g_fSpeedCap[ playerid ];
      s_fVZ = ( s_fVZ / s_fLength ) * g_fSpeedCap[ playerid ];
      if ( s_iVehicle )
         SetVehicleVelocity( s_iVehicle, s_fVX, s_fVY, s_fVZ );
      else
         SetPlayerVelocity( playerid, s_fVX, s_fVY, s_fVZ );
   }
}
}
return 1;
}
/*public OnPlayerCommandText( playerid, cmdtext[ ] )
{
if ( !IsPlayerAdmin( playerid ) )
return 0;
if ( !strcmp( \"/myspeedcap\", cmdtext, true, 11 ) )
{
new
   szMessage[ 24 ]
;
if ( !( cmdtext[ 11 ] && cmdtext[ 12 ] ) )
{
   SendClientMessage( playerid, -1, \"USAGE: /myspeedcap [max speed]\" );
   SendClientMessage( playerid, -1, \"USAGE: 0 will disable the speed cap.\" );
   return 1;
}
g_fSpeedCap[ playerid ] = floatstr( cmdtext[ 12 ] );
format( szMessage, sizeof( szMessage ), \"* Speed cap: %0.4f\", g_fSpeedCap[ playerid ] );
SendClientMessage( playerid, 0xFFFF00FF, szMessage );
return 1;
}
return 0;
}*/
public SetPlayerSpeedCap( playerid, Float:value )
{
if ( 0 <= playerid < sizeof( g_fSpeedCap ) )
g_fSpeedCap[ playerid ] = value;
}
public DisablePlayerSpeedCap( playerid )
{
if ( 0 <= playerid < sizeof( g_fSpeedCap ) )
g_fSpeedCap[ playerid ] = 0.0;
}

Script HIBA
« Válasz #10 Dátum: 2012. Január 15. - 13:33:14 »
0 Show voters
Idézetet írta: ɐʞzssǝlosz date=1326579772\" data-ipsquote-contentapp=\"forums\" data-ipsquote-contenttype=\"forums\" data-ipsquote-contentid=\"15557\" data-ipsquote-contentclass=\"forums_Topic
A letöltési link valóban rossz a hozzászólásokban szokás ilyenkor keresgélni ezt találtam:
http://forum.sa-mp.com/showpost.php?p=1253404&postcount=27
És ezt:
http://webcache.googleusercontent.com/search?q=cache:v1dyNP6ivIIJ:realcop228.com/sampreleases/notmine/speedcap.inc+http://realcop228.com/sampreleases/&cd=3&hl=hu&ct=clnk&gl=hu
 
/*
Vehicle speed cap filterscript.
-----------
This makes it possible to limit the maxspeed of vehicles; there are, however, a few things to consider.
* This will not work well on people with high pings.
* This works best with lower server rates.
* Driving at the speed limit will cause the handling to be different; however, if
  used for roleplay, driving real-life like shouldn\'t be an issue with this at all!
How do I get started with this?
First off,
Try it on to see if it works. Load the filterscript, go ingame, and log in with /rcon login.
Now, use the testing command /myspeedcap to see if it works. An example of a value that feels like 50 km/h is 0.3.
So, simply:
/myspeedcap 0.3
Put the macros below in your other scripts and do this for example:
SetPlayerSpeedCap( playerid, 0.3 );
Another example that disables speed cap only for the NRG:
public OnPlayerEnterVehicle( playerid, vehicleid, ispassenger )
{
   new modelid = GetVehicleModel( vehicleid );
   if ( modelid == 522 ) // 522 - NRG-500
      SetPlayerSpeedCap( playerid, 0.4 );
   else
      DisablePlayerSpeedCap( playerid );
}
Put this in other scripts so they can change the speed cap easily.
#define SetPlayerSpeedCap(%0,%1) CallRemoteFunction( \"SetPlayerSpeedCap\", \"if\", %0, %1 )
#define DisablePlayerSpeedCap(%0) CallRemoteFunction( \"DisablePlayerSpeedCap\", \"i\", %0 )
Author: Slice
*/
#include <a_samp>
#include <YSI\\y_hooks>
forward SetPlayerSpeedCap( playerid, Float:value );
forward DisablePlayerSpeedCap( playerid );
new
Float:g_fSpeedCap[ MAX_PLAYERS ] = { 0.0, ... }
;
hook OnPlayerUpdate(playerid)
{
static
s_iVehicle
;
if ( g_fSpeedCap[ playerid ] != 0.0 && GetPlayerState( playerid ) == PLAYER_STATE_DRIVER )
{
s_iVehicle = GetPlayerVehicleID( playerid );
if ( s_iVehicle )
{
   static
      Float:s_fX,
      Float:s_fY,
      Float:s_fZ,
      Float:s_fVX,
      Float:s_fVY,
      Float:s_fVZ
   ;
   GetVehiclePos( s_iVehicle, s_fX, s_fY, s_fZ );
   GetVehicleVelocity( s_iVehicle, s_fVX, s_fVY, s_fVZ );
   if ( !IsPlayerInRangeOfPoint( playerid, g_fSpeedCap[ playerid ] + 0.05, s_fX + s_fVX, s_fY + s_fVY, s_fZ + s_fVZ ) )
   {
      static
         Float:s_fLength
      ;
      s_fLength = floatsqroot( ( s_fVX * s_fVX ) + ( s_fVY * s_fVY ) + ( s_fVZ * s_fVZ ) );
      s_fVX = ( s_fVX / s_fLength ) * g_fSpeedCap[ playerid ];
      s_fVY = ( s_fVY / s_fLength ) * g_fSpeedCap[ playerid ];
      s_fVZ = ( s_fVZ / s_fLength ) * g_fSpeedCap[ playerid ];
      if ( s_iVehicle )
         SetVehicleVelocity( s_iVehicle, s_fVX, s_fVY, s_fVZ );
      else
         SetPlayerVelocity( playerid, s_fVX, s_fVY, s_fVZ );
   }
}
}
return 1;
}
/*public OnPlayerCommandText( playerid, cmdtext[ ] )
{
if ( !IsPlayerAdmin( playerid ) )
return 0;
if ( !strcmp( \"/myspeedcap\", cmdtext, true, 11 ) )
{
new
   szMessage[ 24 ]
;
if ( !( cmdtext[ 11 ] && cmdtext[ 12 ] ) )
{
   SendClientMessage( playerid, -1, \"USAGE: /myspeedcap [max speed]\" );
   SendClientMessage( playerid, -1, \"USAGE: 0 will disable the speed cap.\" );
   return 1;
}
g_fSpeedCap[ playerid ] = floatstr( cmdtext[ 12 ] );
format( szMessage, sizeof( szMessage ), \"* Speed cap: %0.4f\", g_fSpeedCap[ playerid ] );
SendClientMessage( playerid, 0xFFFF00FF, szMessage );
return 1;
}
return 0;
}*/
public SetPlayerSpeedCap( playerid, Float:value )
{
if ( 0 <= playerid < sizeof( g_fSpeedCap ) )
g_fSpeedCap[ playerid ] = value;
}
public DisablePlayerSpeedCap( playerid )
{
if ( 0 <= playerid < sizeof( g_fSpeedCap ) )
g_fSpeedCap[ playerid ] = 0.0;
}

 

Ebben a kódban 10 error van mégpedig a következõk:
 
C:\\Documents and Settings\\Szabó\\Plocha\\Dunra RPG szerver\\filterscripts\\lassito.pwn(81) : error 010: invalid function or declaration
C:\\Documents and Settings\\Szabó\\Plocha\\Dunra RPG szerver\\filterscripts\\lassito.pwn(83) : error 010: invalid function or declaration
C:\\Documents and Settings\\Szabó\\Plocha\\Dunra RPG szerver\\filterscripts\\lassito.pwn(87) : error 010: invalid function or declaration
C:\\Documents and Settings\\Szabó\\Plocha\\Dunra RPG szerver\\filterscripts\\lassito.pwn(89) : error 010: invalid function or declaration
C:\\Documents and Settings\\Szabó\\Plocha\\Dunra RPG szerver\\filterscripts\\lassito.pwn(95) : error 010: invalid function or declaration
C:\\Documents and Settings\\Szabó\\Plocha\\Dunra RPG szerver\\filterscripts\\lassito.pwn(140) : warning 203: symbol is never used: \"s_fLength\"
C:\\Documents and Settings\\Szabó\\Plocha\\Dunra RPG szerver\\filterscripts\\lassito.pwn(140) : warning 203: symbol is never used: \"s_fVX\"
C:\\Documents and Settings\\Szabó\\Plocha\\Dunra RPG szerver\\filterscripts\\lassito.pwn(140) : warning 203: symbol is never used: \"s_fVY\"
C:\\Documents and Settings\\Szabó\\Plocha\\Dunra RPG szerver\\filterscripts\\lassito.pwn(140) : warning 203: symbol is never used: \"s_fVZ\"
C:\\Documents and Settings\\Szabó\\Plocha\\Dunra RPG szerver\\filterscripts\\lassito.pwn(140) : warning 203: symbol is never used: \"s_fX\"
C:\\Documents and Settings\\Szabó\\Plocha\\Dunra RPG szerver\\filterscripts\\lassito.pwn(140) : warning 203: symbol is never used: \"s_fY\"
C:\\Documents and Settings\\Szabó\\Plocha\\Dunra RPG szerver\\filterscripts\\lassito.pwn(140) : warning 203: symbol is never used: \"s_fZ\"
C:\\Documents and Settings\\Szabó\\Plocha\\Dunra RPG szerver\\filterscripts\\lassito.pwn(140) : warning 203: symbol is never used: \"s_iVehicle\"
Pawn compiler 3.2.3664           Copyright (c) 1997-2006, ITB CompuPhase
 
10 Errors.

Script HIBA
« Válasz #11 Dátum: 2012. Január 15. - 14:18:13 »
0 Show voters
Amit linkeltem azaz .include fájl és nem egy komplett script ami felhasználja az .inc fájlt, sõt nincs is rá szüksége sõt az .inc fájl felhasználja Y_Less y_hooks -inc fájlját ami csak tovább bonyolítja számodra a dolgokat.
Ha talán az example filterscriptet próbálnád átfordítani és alkalmazni több esélyed lenne:
http://spelsajten.net/speedcap.pwn
[pawn]
/*
Vehicle speed cap filterscript.
-----------
This makes it possible to limit the maxspeed of vehicles; there are, however, a few things to consider.
* This will not work well on people with high pings.
* This works best with lower server rates.
* Driving at the speed limit will cause the handling to be different; however, if
  used for roleplay, driving real-life like shouldn\'t be an issue with this at all!
How do I get started with this?
First off,
Try it on to see if it works. Load the filterscript, go ingame, and log in with /rcon login.
Now, use the testing command /myspeedcap to see if it works. An example of a value that feels like 50 km/h is 0.3.
So, simply:
   /myspeedcap 0.3
Put the macros below in your other scripts and do this for example:
   SetPlayerSpeedCap( playerid, 0.3 );
Another example that disables speed cap only for the NRG:
   public OnPlayerEnterVehicle( playerid, vehicleid, ispassenger )
   {
      new modelid = GetVehicleModel( vehicleid );
      if ( modelid == 522 ) // 522 - NRG-500
         SetPlayerSpeedCap( playerid, 0.4 );
      else
         DisablePlayerSpeedCap( playerid );
   }
Put this in other scripts so they can change the speed cap easily.
#define SetPlayerSpeedCap(%0,%1) CallRemoteFunction( \"SetPlayerSpeedCap\", \"if\", %0, %1 )
#define DisablePlayerSpeedCap(%0) CallRemoteFunction( \"DisablePlayerSpeedCap\", \"i\", %0 )
Author: Slice
*/
#include <a_samp>
forward SetPlayerSpeedCap( playerid, Float:value );
forward DisablePlayerSpeedCap( playerid );
new
Float:g_fSpeedCap[ MAX_PLAYERS ] = { 0.0, ... }
;
public OnPlayerUpdate( playerid )
{
static
   s_iVehicle
;
if ( g_fSpeedCap[ playerid ] != 0.0 && GetPlayerState( playerid ) == PLAYER_STATE_DRIVER )
{
   s_iVehicle = GetPlayerVehicleID( playerid );
   if ( s_iVehicle )
   {
      static
         Float:s_fX,
         Float:s_fY,
         Float:s_fZ,
         Float:s_fVX,
         Float:s_fVY,
         Float:s_fVZ
      ;
      GetVehiclePos( s_iVehicle, s_fX, s_fY, s_fZ );
      GetVehicleVelocity( s_iVehicle, s_fVX, s_fVY, s_fVZ );
      if ( !IsPlayerInRangeOfPoint( playerid, g_fSpeedCap[ playerid ] + 0.05, s_fX + s_fVX, s_fY + s_fVY, s_fZ + s_fVZ ) )
      {
         static
            Float:s_fLength
         ;
         s_fLength = floatsqroot( ( s_fVX * s_fVX ) + ( s_fVY * s_fVY ) + ( s_fVZ * s_fVZ ) );
         s_fVX = ( s_fVX / s_fLength ) * g_fSpeedCap[ playerid ];
         s_fVY = ( s_fVY / s_fLength ) * g_fSpeedCap[ playerid ];
         s_fVZ = ( s_fVZ / s_fLength ) * g_fSpeedCap[ playerid ];
         if ( s_iVehicle )
            SetVehicleVelocity( s_iVehicle, s_fVX, s_fVY, s_fVZ );
         else
            SetPlayerVelocity( playerid, s_fVX, s_fVY, s_fVZ );
      }
   }
}
return 1;
}
public OnPlayerCommandText( playerid, cmdtext[ ] )
{
if ( !IsPlayerAdmin( playerid ) )
   return 0;
if ( !strcmp( \"/myspeedcap\", cmdtext, true, 11 ) )
{
   new
      szMessage[ 24 ]
   ;
   if ( !( cmdtext[ 11 ] && cmdtext[ 12 ] ) )
   {
      SendClientMessage( playerid, -1, \"USAGE: /myspeedcap [max speed]\" );
      SendClientMessage( playerid, -1, \"USAGE: 0 will disable the speed cap.\" );
      return 1;
   }
   g_fSpeedCap[ playerid ] = floatstr( cmdtext[ 12 ] );
   format( szMessage, sizeof( szMessage ), \"* Speed cap: %0.4f\", g_fSpeedCap[ playerid ] );
   SendClientMessage( playerid, 0xFFFF00FF, szMessage );
   return 1;
}
return 0;
}
public SetPlayerSpeedCap( playerid, Float:value )
{
if ( 0 <= playerid < sizeof( g_fSpeedCap ) )
   g_fSpeedCap[ playerid ] = value;
}
public DisablePlayerSpeedCap( playerid )
{
if ( 0 <= playerid < sizeof( g_fSpeedCap ) )
   g_fSpeedCap[ playerid ] = 0.0;
}[/pawn]
Benne van a fájl nevében .inc ami sampnál include fájlt jelent amit betöltenek egy forrás (.pwn) fájlba.
Ezért amx fájlt .pwn fájlból kell készíteni és nem .inc fájlból.
Te .inc fájlt próbáltál átkonvertálni.
Edit: Mivel tudom hogy így akarod kipróbálni és csak a parancs fog mûködni ezért a speedcampban szereplõ OnPlayerEnterVehicle részt beleraktam:
[pawn]/*
Vehicle speed cap filterscript.
-----------
This makes it possible to limit the maxspeed of vehicles; there are, however, a few things to consider.
* This will not work well on people with high pings.
* This works best with lower server rates.
* Driving at the speed limit will cause the handling to be different; however, if
  used for roleplay, driving real-life like shouldn\'t be an issue with this at all!
How do I get started with this?
First off,
Try it on to see if it works. Load the filterscript, go ingame, and log in with /rcon login.
Now, use the testing command /myspeedcap to see if it works. An example of a value that feels like 50 km/h is 0.3.
So, simply:
   /myspeedcap 0.3
Put the macros below in your other scripts and do this for example:
   SetPlayerSpeedCap( playerid, 0.3 );
Another example that disables speed cap only for the NRG:
   public OnPlayerEnterVehicle( playerid, vehicleid, ispassenger )
   {
      new modelid = GetVehicleModel( vehicleid );
      if ( modelid == 522 ) // 522 - NRG-500
         SetPlayerSpeedCap( playerid, 0.4 );
      else
         DisablePlayerSpeedCap( playerid );
   }
Put this in other scripts so they can change the speed cap easily.
#define SetPlayerSpeedCap(%0,%1) CallRemoteFunction( \"SetPlayerSpeedCap\", \"if\", %0, %1 )
#define DisablePlayerSpeedCap(%0) CallRemoteFunction( \"DisablePlayerSpeedCap\", \"i\", %0 )
Author: Slice
*/
#include <a_samp>
forward SetPlayerSpeedCap( playerid, Float:value );
forward DisablePlayerSpeedCap( playerid );
new
Float:g_fSpeedCap[ MAX_PLAYERS ] = { 0.0, ... }
;
public OnPlayerUpdate( playerid )
{
static
   s_iVehicle
;
if ( g_fSpeedCap[ playerid ] != 0.0 && GetPlayerState( playerid ) == PLAYER_STATE_DRIVER )
{
   s_iVehicle = GetPlayerVehicleID( playerid );
   if ( s_iVehicle )
   {
      static
         Float:s_fX,
         Float:s_fY,
         Float:s_fZ,
         Float:s_fVX,
         Float:s_fVY,
         Float:s_fVZ
      ;
      GetVehiclePos( s_iVehicle, s_fX, s_fY, s_fZ );
      GetVehicleVelocity( s_iVehicle, s_fVX, s_fVY, s_fVZ );
      if ( !IsPlayerInRangeOfPoint( playerid, g_fSpeedCap[ playerid ] + 0.05, s_fX + s_fVX, s_fY + s_fVY, s_fZ + s_fVZ ) )
      {
         static
            Float:s_fLength
         ;
         s_fLength = floatsqroot( ( s_fVX * s_fVX ) + ( s_fVY * s_fVY ) + ( s_fVZ * s_fVZ ) );
         s_fVX = ( s_fVX / s_fLength ) * g_fSpeedCap[ playerid ];
         s_fVY = ( s_fVY / s_fLength ) * g_fSpeedCap[ playerid ];
         s_fVZ = ( s_fVZ / s_fLength ) * g_fSpeedCap[ playerid ];
         if ( s_iVehicle )
            SetVehicleVelocity( s_iVehicle, s_fVX, s_fVY, s_fVZ );
         else
            SetPlayerVelocity( playerid, s_fVX, s_fVY, s_fVZ );
      }
   }
}
return 1;
}
public OnPlayerCommandText( playerid, cmdtext[ ] )
{
if ( !IsPlayerAdmin( playerid ) )
   return 0;
if ( !strcmp( \"/myspeedcap\", cmdtext, true, 11 ) )
{
   new
      szMessage[ 24 ]
   ;
   if ( !( cmdtext[ 11 ] && cmdtext[ 12 ] ) )
   {
      SendClientMessage( playerid, -1, \"USAGE: /myspeedcap [max speed]\" );
      SendClientMessage( playerid, -1, \"USAGE: 0 will disable the speed cap.\" );
      return 1;
   }
   g_fSpeedCap[ playerid ] = floatstr( cmdtext[ 12 ] );
   format( szMessage, sizeof( szMessage ), \"* Speed cap: %0.4f\", g_fSpeedCap[ playerid ] );
   SendClientMessage( playerid, 0xFFFF00FF, szMessage );
   return 1;
}
return 0;
}
public SetPlayerSpeedCap( playerid, Float:value )
{
if ( 0 <= playerid < sizeof( g_fSpeedCap ) )
   g_fSpeedCap[ playerid ] = value;
}
public DisablePlayerSpeedCap( playerid )
{
if ( 0 <= playerid < sizeof( g_fSpeedCap ) )
   g_fSpeedCap[ playerid ] = 0.0;
}
public OnPlayerEnterVehicle( playerid, vehicleid, ispassenger )
{
new modelid = GetVehicleModel( vehicleid );
if ( modelid == 522 ) // 522 - NRG-500
   SetPlayerSpeedCap( playerid, 0.4 );
else
   DisablePlayerSpeedCap( playerid );
}[/pawn]
« Utoljára szerkesztve: 2012. Január 15. - 14:21:15 írta ɐʞzssǝlosz »

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal