Korisne skripte i kodovi

Započeo Correlli, Mart 10, 2010, 20:26:26 POSLE PODNE

prethodna tema - sledeća tema

0 članova i 3 gostiju pregledaju ovu temu.

Pozdrav svima,
Vidim da je ovaj PF neaktivan i da treba da se malo ukljucimo. Nista toliko tesko ili sa mukom cu vam pokazati dvije jako korisne komande koju dosta njih trazi a ne znaju kako da to urade.

1. Komanda za davanje plaće administraciji ( Mozete i mijenjati za Promotere/Gamemastere itd )



[pawn]
CMD:asplaca(playerid, params[])
{
    new AS_PLACA, string[100], e_Name[24];
    if(sscanf(params,"d",AS_PLACA)) return SendClientMessage( playerid, -1, "{FF8000}[!]: {FFFFFF}/asplaca (kolicina)");
    if(!IsPlayerAdmin(playerid)) return SendClientMessage( playerid, -1, "{FF8000}[!]: {FFFFFF}Nemate ovlasti za koristenje ove komande!");
    GetPlayerName(playerid, e_Name,sizeof(e_Name));
    format( string,sizeof(string), "{FF8000}[ASPLACA] {FFFFFF}Vlasnik: %s je podijelio placu za administraciju u iznosu ($%d)", e_Name, AS_PLACA );
    for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++) if(IsPlayerAdmin(playerid))
    {
        GivePlayerMoney( i, AS_PLACA);
        SendClientMessage( i, -1, string);
    }
    return 1;
}
[/pawn]



Postavite svoju provjeru dali je korisnik administrator/vlasnik:

[pawn]if(!IsPlayerAdmin(playerid)) return SendClientMessage( playerid, -1, "{FF8000}[!]: {FFFFFF}Nemate ovlasti za koristenje ove komande!");[/pawn]




Postavite provjeru dali je igrac admin ili ti administrator kako bi se samo njima slao novac i poslao poruku

[pawn] for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++) if(IsPlayerAdmin(playerid)) //To se nalazi tu if(IsPlayerAdmin(playerid))[/pawn]




2. Komanda za izbacivanje suputnika u vozilu

- Tu vam necu nista objasnjavati, nadam se da znate cemu ovo sluzi

[pawn]
CMD:izbaciputnika( playerid, params[ ] )
{
    new vehicleid, vcount, string[40], e_Name[24], playerstate = GetPlayerState( playerid );
    GetPlayerName(playerid, e_Name,sizeof(e_Name));

   if ( !IsPlayerInAnyVehicle( playerid ) )
      return SendClientMessage( playerid,-1, "Niste ni u jednom vozilu" );

   if ( playerstate == PLAYER_STATE_PASSENGER )
      return SendClientMessage( playerid,-1, "Suputnici ne mogu korisiti ovu komandu!" );

    vehicleid = GetPlayerVehicleID( playerid );

    foreach(new i: Player)
    {
        if ( IsPlayerInVehicle( i, vehicleid ) && i != playerid )
        {
            vcount++;
            RemovePlayerFromVehicle( i );
            format( string,sizeof(string), "Izbaceni ste iz %s vozila", e_Name );
            SendClientMessage( i, -1, string);
        }
   }
    if ( vcount == 0 )
    {
        SendClientMessage( playerid,-1, "Nema suputnika u tvom vozilu" );
        return 1 ;
    }
    return 1 ;
}
[/pawn]

- Uskoro stize jos toga ukoliko nadem vremena. Ako vas nesto zanima i zelite da nesto uradim pitajte ovdje !




Former Developer | COD: Lords Of War - Modern Warfare 3 | Stunt Planet | Global Warfare |


Hvala, Inace ako imate kakva pitanja, ili trebate komande bla bla pitajte ovdje. Dok imam vremena uradim nesto na brzinu
Former Developer | COD: Lords Of War - Modern Warfare 3 | Stunt Planet | Global Warfare |

Jedan kod koji sam uradio iz dosade, radio sam nekih 5 min (nisam testirao al trebalo bi raditi)

[pawn]CMD:makechatbubble(playerid, params[])
{
   new id,tekst[20],drawdistanca,globalni[128];
   if(sscanf(params,"u[24]s[20]i",id,tekst,drawdistanca)) return SendClientMessage(playerid, -1, "/makechatbubble (playername/id) (tekst - max 20 slova) (draw distanca)");
   if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "Korisnik nije na serveru!");
   if(strlen(tekst) < 1 || strlen(tekst) > 20) return SendClientMessage(playerid, -1, "Tekst ne moze biti manji od 1 slova ili veci od 20 slova!");
   if(drawdistanca < 5 || drawdistanca > 15) return SendClientMessage(playerid, -1, "Draw distanca ne moze biti manja od 5 i veca od 15");
   SetPlayerChatBubble(id, tekst, 0xFFFFFFFF, drawdistanca, 86400000);
   format(globalni,sizeof(globalni), "Igraču %s ste postavili chat bubble sa tekstom %s", GetName(id), tekst);
   SendClientMessage(playerid, -1, globalni);
   format(globalni,sizeof(globalni), "Administrator %s vam je postavio chat bubble sa tekstom %s!", GetName(playerid), tekst);
   SendClientMessage(id, -1, globalni);
   return 1;
}[/pawn]

[pawn]GetName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
[/pawn]
heroin rap - Moskri u kuci, od sledece lajne glava ce mi puci

Evo kod da vam vas server ne crasha.
------------------------------------------------------------
[pawn]//=======================================[ AntiCrasher by Cyllox ]=======================================//
public OnPlayerUpdate(playerid)
{
    if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) {
    new Float:vec[3];
    GetPlayerCameraFrontVector(playerid, vec[0], vec[1], vec[2]);
    new bool:possible_crasher = false; for (new i = 0; !possible_crasher && i < sizeof(vec); i++)
    if (floatabs(vec) > 10.0) possible_crasher = true;
    if (possible_crasher) return 1;
}
[/pawn]
------------------------------------------------------------
Nadam se da ce vam pomoci :)
• Website: www.vasic.dev
Web Development & Cyber Security

Kao sto kazu, ProxDetector je malo zastareo, pa sam uradio malo jednostavnije:

Inlcude Foreach mozete skinete ovde: KLINKI

[pawn]stock RadiusPoruka(Float:Radius, playerid, color, const string[])
{
   new Float:Pos[3];
   GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
   foreach(new i : Player)
   {
      if( IsPlayerInRangeOfPoint(i, Radius, Pos[0], Pos[1], Pos[2]))
      {
         SendClientMessage(i, color, string);
      }
   }
   return false;
}[/pawn]

Citat: RESPOSNE poslato Maj 20, 2017, 12:31:44 POSLE PODNE
Kao sto kazu, ProxDetector je malo zastareo, pa sam uradio malo jednostavnije:

Inlcude Foreach mozete skinete ovde: KLINKI

[pawn]stock RadiusPoruka(Float:Radius, playerid, color, const string[])
{
   new Float:Pos[3];
   GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
   foreach(new i : Player)
   {
      if( IsPlayerInRangeOfPoint(i, Radius, Pos[0], Pos[1], Pos[2]))
      {
         SendClientMessage(i, color, string);
      }
   }
   return false;
}[/pawn]
[pawn]RadiusPoruka(Float:Radius, playerid, color, const string[])
{
    new Float:PosX,Float:PosY,Float:PosZ;
    GetPlayerPos(playerid, PosX, PosY, PosZ);
    foreach(Player, i)
    {
        if(IsPlayerInRangeOfPoint(i, Radius, PosX, PosY, PosZ))
        {
            SendClientMessage(i, color, string);
        }
    }
    return false;
}[/pawn]
Eto poboljsano zbog memorije, gj za ovo :D
heroin rap - Moskri u kuci, od sledece lajne glava ce mi puci

Evo uradio sam nesto sto je mnogo bolje i manje pisanje na jednoj linija, u vezi dozvole, logovanja i ostalih errora za komande.

[pawn]PRIMER:

if(PlayerInfo[playerid][pAdmin] < 4) return errorMessage(playerid, 1); // Kao sto je uradjeno pod stockom, samo stavimo mesto teksta id te poruke koju zelite da stavite.
if(UlogovanProvera[playerid] == 0) return errorMessage(playerid, 2); // Sada smo stavili id 2 to je kada je igrac na loginu ili registeru da mu izadje text pod id 2.

stock errorMessage(playerid, id)
{
   switch(id)
   {
       case 01: SendErrorMessage(playerid, "Nemate dozvolu da koristite ovu komandu.");
       case 02: SendErrorMessage(playerid, "Morate biti ulogovani da bi ste koristili komandu.");
       case 03: SendErrorMessage(playerid, "Morate biti na duznosti da bi ste koristili komandu.");
       case 04: SendErrorMessage(playerid, "Odabrani igrac je van mreze.");
   }
   return 1;
}
[/pawn]

Citat: RESPOSNE poslato Maj 21, 2017, 21:01:07 POSLE PODNE
Evo uradio sam nesto sto je mnogo bolje i manje pisanje na jednoj linija, u vezi dozvole, logovanja i ostalih errora za komande.

[pawn]PRIMER:

if(PlayerInfo[playerid][pAdmin] < 4) return errorMessage(playerid, 1); // Kao sto je uradjeno pod stockom, samo stavimo mesto teksta id te poruke koju zelite da stavite.
if(UlogovanProvera[playerid] == 0) return errorMessage(playerid, 2); // Sada smo stavili id 2 to je kada je igrac na loginu ili registeru da mu izadje text pod id 2.

stock errorMessage(playerid, id)
{
   switch(id)
   {
       case 01: SendErrorMessage(playerid, "Nemate dozvolu da koristite ovu komandu.");
       case 02: SendErrorMessage(playerid, "Morate biti ulogovani da bi ste koristili komandu.");
       case 03: SendErrorMessage(playerid, "Morate biti na duznosti da bi ste koristili komandu.");
       case 04: SendErrorMessage(playerid, "Odabrani igrac je van mreze.");
   }
   return 1;
}
[/pawn]
Dobra ideja, good job. :)

Citat: Łukmember=1996][/member] link=topic=4245.msg727852#msg727852 date=1495382000]
Citat: RESPOSNE poslato Maj 20, 2017, 12:31:44 POSLE PODNE
Kao sto kazu, ProxDetector je malo zastareo, pa sam uradio malo jednostavnije:

Inlcude Foreach mozete skinete ovde: KLINKI

[pawn]stock RadiusPoruka(Float:Radius, playerid, color, const string[])
{
   new Float:Pos[3];
   GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
   foreach(new i : Player)
   {
      if( IsPlayerInRangeOfPoint(i, Radius, Pos[0], Pos[1], Pos[2]))
      {
         SendClientMessage(i, color, string);
      }
   }
   return false;
}[/pawn]
[pawn]RadiusPoruka(Float:Radius, playerid, color, const string[])
{
    new Float:PosX,Float:PosY,Float:PosZ;
    GetPlayerPos(playerid, PosX, PosY, PosZ);
    foreach(Player, i)
    {
        if(IsPlayerInRangeOfPoint(i, Radius, PosX, PosY, PosZ))
        {
            SendClientMessage(i, color, string);
        }
    }
    return false;
}[/pawn]
Eto poboljsano zbog memorije, gj za ovo :D

Hvala :)

Citat: anDro_ poslato Maj 21, 2017, 21:04:41 POSLE PODNE
Citat: RESPOSNE poslato Maj 21, 2017, 21:01:07 POSLE PODNE
Evo uradio sam nesto sto je mnogo bolje i manje pisanje na jednoj linija, u vezi dozvole, logovanja i ostalih errora za komande.

[pawn]PRIMER:

if(PlayerInfo[playerid][pAdmin] < 4) return errorMessage(playerid, 1); // Kao sto je uradjeno pod stockom, samo stavimo mesto teksta id te poruke koju zelite da stavite.
if(UlogovanProvera[playerid] == 0) return errorMessage(playerid, 2); // Sada smo stavili id 2 to je kada je igrac na loginu ili registeru da mu izadje text pod id 2.

stock errorMessage(playerid, id)
{
   switch(id)
   {
       case 01: SendErrorMessage(playerid, "Nemate dozvolu da koristite ovu komandu.");
       case 02: SendErrorMessage(playerid, "Morate biti ulogovani da bi ste koristili komandu.");
       case 03: SendErrorMessage(playerid, "Morate biti na duznosti da bi ste koristili komandu.");
       case 04: SendErrorMessage(playerid, "Odabrani igrac je van mreze.");
   }
   return 1;
}
[/pawn]
Dobra ideja, good job. :)

Hvala :)

Uradio sam System Reporta, Svako ko zeli da koristi ovaj system neka prilagodi svom modu.

[pawn]//==============================================================================
//                          SYSTEM REPORT
//                     SCRIPTED BY RESPONSE
//                          VERSION v1.0
//==============================================================================
#include <YSI\y_hooks>
#include <YSI\y_va>
#include <sscanf2>
#include <zcmd>
//==============================================================================
#define MAX_REPORTS 10
//==============================================================================
enum report
{
   report_ID,
   report_Name[MAX_PLAYER_NAME+1],
   report_Text[200],
   report_Answer[200],
}
new reportInfo[MAX_REPORTS][report];
//==============================================================================
enum fullReport
{
   full_Reports,
}
new fullInfo[fullReport];
//==============================================================================
enum playerReport
{
   player_Report,
   player_Reported,
   player_Reports[200],
}
new playerInfo[MAX_PLAYERS][playerReport];
//==============================================================================
// Moze da stavite komandu CMD: ili YCMD:(TO AKO KORISTITE y_commands);
command(report, playerid, params[])
{
   new text[200];
   if(playerInfo[playerid][player_Report] == 1) return SendClientMessage(playerid, -1, "Vec imate postavljen report!");
   if(fullInfo[full_Reports] == 10) return SendClientMessage(playerid, -1, "Trenutno ne mozete postaviti report!");
   if(sscanf(params, "s[200]", text)) return SendClientMessage(playerid, -1,  "/report [Text]");
   creatingReport(reportingID, text, GetName(playerid));
   fullInfo[full_Reports]++;
   playerInfo[playerid][player_Reported] = fullInfo[full_Reports];
   
   SendClientMessage(playerid, -1, "Vas report je poslat, administracija ga trenutno obradjuje!");
   SendClientMessage(playerid, -1, "Da vidite odgovor na vas report kucajte -> '/viewasnwer'.");
   return 1;
}
//==============================================================================
// Moze da stavite komandu CMD: ili YCMD:(TO AKO KORISTITE y_commands);
command(viewanswer, playerid, params[])
{
    new id = playerInfo[playerid][player_Reported];
    if(playerInfo[playerid][player_Report] == 0) return SendClientMessage(playerid, -1, "Nemate postavljen report!");
    format(playerInfo[playerid][player_Reports], 200, reportInfo[id][report_Answer]);
    va_SendClientMessage(playerid, -1, "'%s'.", playerInfo[playerid][player_Reports]);
   
    playerInfo[playerid][player_Report] = 0;
    playerInfo[playerid][player_Reported] = -1;
    format(playerInfo[playerid][player_Reports], 200, "Empty");
    fullInfo[full_Reports]--;
    return 1;
}
//==============================================================================
stock creatingReport(reportingID, reportingText[200], reportingName[MAX_PLAYER_NAME+1]) // Kreiraj report fajl;
{
    reportInfo[reportingID][report_ID] = fullInfo[full_Reports];
    format(reportInfo[reportingID][report_Name], MAX_PLAYER_NAME+1, reportingName);
    format(reportInfo[reportingID][report_Text], 200, reportingText);
    format(reportInfo[reportingID][report_Answer], 200, "Empty");
    return 1;
}
//==============================================================================[/pawn]


Citat: RESPOSNE poslato Maj 28, 2017, 20:25:17 POSLE PODNE
Uradio sam System Reporta, Svako ko zeli da koristi ovaj system neka prilagodi svom modu.

[pawn]//==============================================================================
//                          SYSTEM REPORT
//                     SCRIPTED BY RESPONSE
//                          VERSION v1.0
//==============================================================================
#include <YSI\y_hooks>
#include <YSI\y_va>
#include <sscanf2>
#include <zcmd>
//==============================================================================
#define MAX_REPORTS 10
//==============================================================================
enum report
{
   report_ID,
   report_Name[MAX_PLAYER_NAME+1],
   report_Text[200],
   report_Answer[200],
}
new reportInfo[MAX_REPORTS][report];
//==============================================================================
enum fullReport
{
   full_Reports,
}
new fullInfo[fullReport];
//==============================================================================
enum playerReport
{
   player_Report,
   player_Reported,
   player_Reports[200],
}
new playerInfo[MAX_PLAYERS][playerReport];
//==============================================================================
// Moze da stavite komandu CMD: ili YCMD:(TO AKO KORISTITE y_commands);
command(report, playerid, params[])
{
   new text[200];
   if(playerInfo[playerid][player_Report] == 1) return SendClientMessage(playerid, -1, "Vec imate postavljen report!");
   if(fullInfo[full_Reports] == 10) return SendClientMessage(playerid, -1, "Trenutno ne mozete postaviti report!");
   if(sscanf(params, "s[200]", text)) return SendClientMessage(playerid, -1,  "/report [Text]");
   creatingReport(reportingID, text, GetName(playerid));
   fullInfo[full_Reports]++;
   playerInfo[playerid][player_Reported] = fullInfo[full_Reports];
   
   SendClientMessage(playerid, -1, "Vas report je poslat, administracija ga trenutno obradjuje!");
   SendClientMessage(playerid, -1, "Da vidite odgovor na vas report kucajte -> '/viewasnwer'.");
   return 1;
}
//==============================================================================
// Moze da stavite komandu CMD: ili YCMD:(TO AKO KORISTITE y_commands);
command(viewanswer, playerid, params[])
{
    new id = playerInfo[playerid][player_Reported];
    if(playerInfo[playerid][player_Report] == 0) return SendClientMessage(playerid, -1, "Nemate postavljen report!");
    format(playerInfo[playerid][player_Reports], 200, reportInfo[id][report_Answer]);
    va_SendClientMessage(playerid, -1, "'%s'.", playerInfo[playerid][player_Reports]);
   
    playerInfo[playerid][player_Report] = 0;
    playerInfo[playerid][player_Reported] = -1;
    format(playerInfo[playerid][player_Reports], 200, "Empty");
    fullInfo[full_Reports]--;
    return 1;
}
//==============================================================================
stock creatingReport(reportingID, reportingText[200], reportingName[MAX_PLAYER_NAME+1]) // Kreiraj report fajl;
{
    reportInfo[reportingID][report_ID] = fullInfo[full_Reports];
    format(reportInfo[reportingID][report_Name], MAX_PLAYER_NAME+1, reportingName);
    format(reportInfo[reportingID][report_Text], 200, reportingText);
    format(reportInfo[reportingID][report_Answer], 200, "Empty");
    return 1;
}
//==============================================================================[/pawn]

Izaci ce vam Error za GetName, evo vam i taj kod, naravno ko nema u modu, a ko ima, nece da pravi nikakve probleme, enjoy! :D

[pawn]stock GetName(playerid)
{
   new Ime_Igraca[MAX_PLAYER_NAME];
   GetPlayerName(playerid, Ime_Igraca, MAX_PLAYER_NAME);
   return Ime_Igraca;
}[/pawn]

Citat: RESPOSNE poslato Maj 28, 2017, 20:31:21 POSLE PODNE
Citat: RESPOSNE poslato Maj 28, 2017, 20:25:17 POSLE PODNE
Uradio sam System Reporta, Svako ko zeli da koristi ovaj system neka prilagodi svom modu.

[pawn]//==============================================================================
//                          SYSTEM REPORT
//                     SCRIPTED BY RESPONSE
//                          VERSION v1.0
//==============================================================================
#include <YSI\y_hooks>
#include <YSI\y_va>
#include <sscanf2>
#include <zcmd>
//==============================================================================
#define MAX_REPORTS 10
//==============================================================================
enum report
{
   report_ID,
   report_Name[MAX_PLAYER_NAME+1],
   report_Text[200],
   report_Answer[200],
}
new reportInfo[MAX_REPORTS][report];
//==============================================================================
enum fullReport
{
   full_Reports,
}
new fullInfo[fullReport];
//==============================================================================
enum playerReport
{
   player_Report,
   player_Reported,
   player_Reports[200],
}
new playerInfo[MAX_PLAYERS][playerReport];
//==============================================================================
// Moze da stavite komandu CMD: ili YCMD:(TO AKO KORISTITE y_commands);
command(report, playerid, params[])
{
   new text[200];
   if(playerInfo[playerid][player_Report] == 1) return SendClientMessage(playerid, -1, "Vec imate postavljen report!");
   if(fullInfo[full_Reports] == 10) return SendClientMessage(playerid, -1, "Trenutno ne mozete postaviti report!");
   if(sscanf(params, "s[200]", text)) return SendClientMessage(playerid, -1,  "/report [Text]");
   creatingReport(reportingID, text, GetName(playerid));
   fullInfo[full_Reports]++;
   playerInfo[playerid][player_Reported] = fullInfo[full_Reports];
   
   SendClientMessage(playerid, -1, "Vas report je poslat, administracija ga trenutno obradjuje!");
   SendClientMessage(playerid, -1, "Da vidite odgovor na vas report kucajte -> '/viewasnwer'.");
   return 1;
}
//==============================================================================
// Moze da stavite komandu CMD: ili YCMD:(TO AKO KORISTITE y_commands);
command(viewanswer, playerid, params[])
{
    new id = playerInfo[playerid][player_Reported];
    if(playerInfo[playerid][player_Report] == 0) return SendClientMessage(playerid, -1, "Nemate postavljen report!");
    format(playerInfo[playerid][player_Reports], 200, reportInfo[id][report_Answer]);
    va_SendClientMessage(playerid, -1, "'%s'.", playerInfo[playerid][player_Reports]);
   
    playerInfo[playerid][player_Report] = 0;
    playerInfo[playerid][player_Reported] = -1;
    format(playerInfo[playerid][player_Reports], 200, "Empty");
    fullInfo[full_Reports]--;
    return 1;
}
//==============================================================================
stock creatingReport(reportingID, reportingText[200], reportingName[MAX_PLAYER_NAME+1]) // Kreiraj report fajl;
{
    reportInfo[reportingID][report_ID] = fullInfo[full_Reports];
    format(reportInfo[reportingID][report_Name], MAX_PLAYER_NAME+1, reportingName);
    format(reportInfo[reportingID][report_Text], 200, reportingText);
    format(reportInfo[reportingID][report_Answer], 200, "Empty");
    return 1;
}
//==============================================================================[/pawn]

Izaci ce vam Error za GetName, evo vam i taj kod, naravno ko nema u modu, a ko ima, nece da pravi nikakve probleme, enjoy! :D

[pawn]stock GetName(playerid)
{
   new Ime_Igraca[MAX_PLAYER_NAME];
   GetPlayerName(playerid, Ime_Igraca, MAX_PLAYER_NAME);
   return Ime_Igraca;
}[/pawn]

stock izbriši, stavi samo

[pawn]GetName(playerid)
{
   new Ime_Igraca[MAX_PLAYER_NAME];
   GetPlayerName(playerid, Ime_Igraca, MAX_PLAYER_NAME);
   return Ime_Igraca;
}
[/pawn]
TakoÄ'er rekao sam ti i za bool, gj :)
heroin rap - Moskri u kuci, od sledece lajne glava ce mi puci

kakve veze ima to sa stockom vidim spominjes vec par puta ?
to apsolutno nikakve veze nema, stock koristis samo ako funkciju pozivas vise puta ili nikako a suprotno ako je pozivas sigurno.
sve je stvar navike ako je navikao sa stockom neka pise tako, to je isto kao da si ti desnjak i neko ti dodje i natera da pises levom rukom.