[Pomoc]Mjesanje

Započeo JuustyGe, Oktobar 02, 2010, 17:40:43 POSLE PODNE

prethodna tema - sledeća tema

0 članova i 2 gostiju pregledaju ovu temu.

Pravio sam neke komande i evo ih ali imam problem

public OnPlayerCommandText(playerid, cmdtext[])
{
    new string[256];
    new sendername[MAX_PLAYER_NAME];
    new giveplayer[MAX_PLAYER_NAME];
    new cmd[256];
    new gMessage[256];
    new idx;
    new tmp[256];
    new giveplayerid, moneys;

    if(strcmp(cmd, "/createcash", true) == 0) {
  tmp = strtok(cmdtext, idx);

        if(strlen(cmdtext[8])) {
            SendClientMessage(playerid, 0x17E3DC, "Koristite: /createcash [playerid] [kolicina]");
            return 1;
        }
        giveplayerid = strval(tmp);
        if (IsPlayerConnected(giveplayerid)) {
            GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
            GetPlayerName(playerid, sendername, sizeof(sendername));
                GivePlayerMoney(giveplayerid, moneys);
                format(string, sizeof(string), "Poslao si %s %d$", giveplayer, moneys);
                SendClientMessage(playerid, 0x17E3DC, string);
                format(string, sizeof(string), "Admin %s ti je poslo %d$", sendername,moneys);
                SendClientMessage(giveplayerid, 0x17E3DC, string);
                }
        return 1;
    }



    if(strcmp(cmdtext, "/unmute", true, 7))
{
    if(strlen(cmdtext[8]))
    {
        SendClientMessage(playerid, 0x17E3DC, "Koristite: /unmute [playerid]");
        return 1;
    }
    new ID = strval(cmdtext[8]);
    new pName[24], unmuteername[24], stri[64], strv[256];
    tmp = strtok(cmdtext,idx);
    gMessage = strrest(cmdtext,idx);
    if(IsPlayerConnected(ID))
    {
        GetPlayerName(ID, pName, 24);
        GetPlayerName(playerid, unmuteername, 24);
            if(IsPlayerNPC(ID))
{
     SendClientMessage(playerid, 0x17E3DC, "Nemozes ukinuti NPC-u zabranu da govori");
     return 1;
}
    if(ID == playerid)
{
     SendClientMessage(playerid, 0x17E3DC, "Nemozes ukinuti zabranu samom sebi da govoris");
     return 1;
}
        format(strv, 64, "Ukinuta vam je zabrana da govorite");
        SendClientMessage(ID,0x17E3DC, strv);
        Muted[ID] = 0;
        format(stri, 64, "%s je ukinuta zabrana da govori", pName);
        SendClientMessageToAll(0x17E3DC, stri);
        printf("Admin %s je ukinuo %s  zabranu da govori", unmuteername, pName);
    }
    return 1;

    }
   
   
   
   
   
    if(strcmp(cmdtext, "/mute", true, 5))
{
    if(strlen(cmdtext[6]))
    {
        SendClientMessage(playerid, 0x17E3DC, "Koristite: /mute [playerid]");
        return 1;
    }
    new ID = strval(cmdtext[6]);
    new pName[24], muteername[24], stri[64], strv[256];
    tmp = strtok(cmdtext,idx);
    gMessage = strrest(cmdtext,idx);
    if(IsPlayerConnected(ID))
    {
        GetPlayerName(ID, pName, 24);
        GetPlayerName(playerid, muteername, 24);
            if(IsPlayerNPC(ID))
{
     SendClientMessage(playerid, 0x17E3DC, "Nemozes zabraniti NPC-u da govori");
     return 1;
}
    if(ID == playerid)
{
     SendClientMessage(playerid, 0x17E3DC, "Nemozes zabraniti samom sebi da govoris");
     return 1;
}
        format(strv, 64, "Zabranjeno vam je da govorite");
        SendClientMessage(ID,0x17E3DC, strv);
        Muted[ID] = 1;
        format(stri, 64, "%s je zabranjeno da govori", pName);
        SendClientMessageToAll(0x17E3DC, stri);
        printf("Admin %s je zabranio %s da govori", muteername, pName);
    }
    return 1;

    }
   
   
   
   
    if(strcmp(cmdtext, "/kick", true, 5))
{
    if(strlen(cmdtext[6]))
    {
        SendClientMessage(playerid,0x17E3DC , "Koristite: /kick [playerid] [razlog]");
        return 1;
    }
    new ID = strval(cmdtext[6]);
    new pName[24], kickername[24], stri[64], strv[256];
    tmp = strtok(cmdtext,idx);
    gMessage = strrest(cmdtext,idx);
    if(IsPlayerConnected(ID))
    {
         GetPlayerName(ID, pName, 24);
        GetPlayerName(playerid, kickername, 24);
            if(IsPlayerNPC(ID))
{
     SendClientMessage(playerid, 0x17E3DC, "Nemozes kickati NPC-a");
     return 1;
}
    if(ID == playerid)
{
     SendClientMessage(playerid, 0x17E3DC, "Nemozes kickati samog sebe");
     return 1;
}
     format(strv, 64, "%s kickani ste sa ovoga servera", gMessage);
        SendClientMessage(ID,0x17E3DC, strv);
        Kick(ID);
        format(stri, 64, "%s je kickan sa servera zbog %s", pName,gMessage);
        SendClientMessageToAll(0x17E3DC, stri);
        printf("Admin %s je kickao %s zbog %s", kickername, pName,gMessage);
    }
    return 1;

    }

    if (strcmp("/pravila", cmdtext, true, 10) == 0)
    {
        SendClientMessage(playerid, 0x17E3DC, "----------- PRAVILA --------------------- Extesna DeathMatch ----------");
        SendClientMessage(playerid, 0x17E3DC, " ");
        SendClientMessage(playerid, 0x17E3DC, " Zabranjeno je koristiti cheat ili neki hack u svoju ili tudju korist");
        SendClientMessage(playerid, 0x17E3DC, " Zabranjen je BUG ABUSING ili koristenje bugova koji daju korist");
        SendClientMessage(playerid, 0x17E3DC, " Zabranjeno je psovanje ili neko drugo vrijedajnje igraca");
        SendClientMessage(playerid, 0x17E3DC, " Zabranjen je SPAWN KILL ili ubijanje na mjestu stvaranja igraca");
        SendClientMessage(playerid, 0x17E3DC, " Obavezno slusati i postavati admine kao i druge igrace");
        SendClientMessage(playerid, 0x17E3DC, " ");
        SendClientMessage(playerid, 0x17E3DC, " ----- Admin Team: Go0[G]Le, JuustyGe ---------------------------------");

        return 1;
    }
   
    if (strcmp ("/webinfo", cmdtext, true, 10) == 0)
    {
       SendClientMessage(playerid, 0x17E3DC, "----------- WEB --------------------------- Extesna DeathMach ----------");
       SendClientMessage(playerid, 0x17E3DC, " ");
       SendClientMessage(playerid, 0x17E3DC, " Forum je u izradi");
       SendClientMessage(playerid, 0x17E3DC, " ");
       SendClientMessage(playerid, 0x17E3DC, "------------------------------------------------------------------------");
       
       return 1;
    }
   
    if (strcmp ("/komande", cmdtext, true, 10) == 0)
    {
       SendClientMessage(playerid, 0x17E3DC, "----------- KOMANDE ----------------------- Extesna DeathMach ----------");
       SendClientMessage(playerid, 0x17E3DC, " ");
       SendClientMessage(playerid, 0x17E3DC, " /pravila - lista pravila kaja se moraju postovati");
       SendClientMessage(playerid, 0x17E3DC, " /webinfo - web stranica nasega foruma");
       SendClientMessage(playerid, 0x17E3DC, " /komande - lista komandi koje mozete koristiti na serveru");
       SendClientMessage(playerid, 0x17E3DC, " ");
       SendClientMessage(playerid, 0x17E3DC, "------------------------------------------------------------------------");

       return 1;
    }
    if (strcmp ("/kill", cmdtext, true, 10) == 0)
    {
       SetPlayerHealth(playerid,0);

       return 1;
    }
    if (strcmp ("/ahelp", cmdtext, true, 10) == 0)
    {
       SendClientMessage(playerid, 0x17E3DC, "----------- ADMIN KOMANDE ----------------- Extesna DeathMach ----------");
       SendClientMessage(playerid, 0x17E3DC, " ");
       SendClientMessage(playerid, 0x17E3DC, "/ban - banati igraca");
       SendClientMessage(playerid, 0x17E3DC, "/kick - kickati igraca");
       SendClientMessage(playerid, 0x17E3DC, "/mute - zabraniti igracu da govori");
       SendClientMessage(playerid, 0x17E3DC, "/unmute - ukinuti zbranu igracu da govori");
       SendClientMessage(playerid, 0x17E3DC, "/freeze - zabraniti igracu da se mice");
       SendClientMessage(playerid, 0x17E3DC, "/unfreeze - ukinuti zabranu igracu da se mice");
       SendClientMessage(playerid, 0x17E3DC, "/createcash - stvoriti pare");
       SendClientMessage(playerid, 0x17E3DC, " ");
       SendClientMessage(playerid, 0x17E3DC, "------------------------------------------------------------------------");

       return 1;
    }
    if(strcmp(cmdtext, "/ban", true, 4))
{
    if(strlen(cmdtext[5]))
    {
        SendClientMessage(playerid, 0x17E3DC, "Koristite: /ban [playerid] [razlog]");
        return 1;
    }
    new ID = strval(cmdtext[5]);
    new pName[24], banername[24], stri[64], strv[256];
    tmp = strtok(cmdtext,idx);
    gMessage = strrest(cmdtext,idx);
    if(IsPlayerConnected(ID))
    {
        GetPlayerName(ID, pName, 24);
        GetPlayerName(playerid, banername, 24);
            if(IsPlayerNPC(ID))
{
     SendClientMessage(playerid, 0x17E3DC, "Nemozes banati NPC-a");
     return 1;
}
    if(ID == playerid)
{
     SendClientMessage(playerid, 0x17E3DC, "Nemozes banati samog sebe");
     return 1;
}
        format(strv, 64, " %s banan si sa ovoga servera", gMessage);
        SendClientMessage(ID,0x17E3DC, strv);
        Ban(ID);
        format(stri, 64, "%s je banan zbog %s", pName,gMessage);
        SendClientMessageToAll(0x17E3DC, stri);
        printf("Admin %s je banao %s zbog %s", banername, pName,gMessage);
    }
    return 1;
    }
   

    return SendClientMessage(playerid, 0xFFFFFF, "Nepostojeca komanda");
}


kada upisem svaku komandu koju sam napravio kaze  "Koristite: /createcash [playerid] [kolicina]" ili kad upisem /bdhbsfbdsibvdsi ono kaze "Poslao si JuustyGe 0$" i "Admin JustyGe je poslao JuustyGe 0 $" kako to rijesit

Nisam bas profesionalac, ali imas par puta "if" a nigdje nemas "else"  ?   haha.   Nisi ti dobro uradio tu komandu.
Povratak na balkan-samp  :)  15.01.2013. 
..   


Respect : [BP]HeLoX, Correlli, [CH:FR]Djea, LordShigi, LuKsA, BloodMaster, [H]265


Citat: [βР] AlÑ"Ñ"N MÑ"кA poslato Oktobar 02, 2010, 17:54:25 POSLE PODNE
Nisam bas profesionalac, ali imas par puta "if" a nigdje nemas "else"  ?   haha.   Nisi ti dobro uradio tu komandu.

else ti netreba nekad, else ti ide ako oces da playeru nesta napravi server ..................npr da sa if..blablabla provjeris jeli player admin da moze koristit tu komandu i onda ide else pa mu server kaze npr "Nisi ovlasten za koristenje ove komande" ali i netreba mu rec to nisi ovlasten blablabla



juustyge daj stavi umjesto u code napisi ovo u code=c pls ovak nemogu nis nekuzim

public OnPlayerCommandText(playerid, cmdtext[])
{
    new string[256];
    new sendername[MAX_PLAYER_NAME];
    new giveplayer[MAX_PLAYER_NAME];
    new cmd[256];
    new gMessage[256];
    new idx;
    new tmp[256];
    new giveplayerid, moneys;

    if(strcmp(cmd, "/createcash", true) == 0) {
  tmp = strtok(cmdtext, idx);

        if(strlen(cmdtext[8])) {
            SendClientMessage(playerid, 0x17E3DC, "Koristite: /createcash [playerid] [kolicina]");
            return 1;
        }
        giveplayerid = strval(tmp);
        if (IsPlayerConnected(giveplayerid)) {
            GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
            GetPlayerName(playerid, sendername, sizeof(sendername));
                GivePlayerMoney(giveplayerid, moneys);
                format(string, sizeof(string), "Poslao si %s %d$", giveplayer, moneys);
                SendClientMessage(playerid, 0x17E3DC, string);
                format(string, sizeof(string), "Admin %s ti je poslo %d$", sendername,moneys);
                SendClientMessage(giveplayerid, 0x17E3DC, string);
                }
        return 1;
    }



    if(strcmp(cmdtext, "/unmute", true, 7))
{
    if(strlen(cmdtext[8]))
    {
        SendClientMessage(playerid, 0x17E3DC, "Koristite: /unmute [playerid]");
        return 1;
    }
    new ID = strval(cmdtext[8]);
    new pName[24], unmuteername[24], stri[64], strv[256];
    tmp = strtok(cmdtext,idx);
    gMessage = strrest(cmdtext,idx);
    if(IsPlayerConnected(ID))
    {
        GetPlayerName(ID, pName, 24);
        GetPlayerName(playerid, unmuteername, 24);
            if(IsPlayerNPC(ID))
{
     SendClientMessage(playerid, 0x17E3DC, "Nemozes ukinuti NPC-u zabranu da govori");
     return 1;
}
    if(ID == playerid)
{
     SendClientMessage(playerid, 0x17E3DC, "Nemozes ukinuti zabranu samom sebi da govoris");
     return 1;
}
        format(strv, 64, "Ukinuta vam je zabrana da govorite");
        SendClientMessage(ID,0x17E3DC, strv);
        Muted[ID] = 0;
        format(stri, 64, "%s je ukinuta zabrana da govori", pName);
        SendClientMessageToAll(0x17E3DC, stri);
        printf("Admin %s je ukinuo %s  zabranu da govori", unmuteername, pName);
    }
    return 1;

    }
   
   
   
   
   
    if(strcmp(cmdtext, "/mute", true, 5))
{
    if(strlen(cmdtext[6]))
    {
        SendClientMessage(playerid, 0x17E3DC, "Koristite: /mute [playerid]");
        return 1;
    }
    new ID = strval(cmdtext[6]);
    new pName[24], muteername[24], stri[64], strv[256];
    tmp = strtok(cmdtext,idx);
    gMessage = strrest(cmdtext,idx);
    if(IsPlayerConnected(ID))
    {
        GetPlayerName(ID, pName, 24);
        GetPlayerName(playerid, muteername, 24);
            if(IsPlayerNPC(ID))
{
     SendClientMessage(playerid, 0x17E3DC, "Nemozes zabraniti NPC-u da govori");
     return 1;
}
    if(ID == playerid)
{
     SendClientMessage(playerid, 0x17E3DC, "Nemozes zabraniti samom sebi da govoris");
     return 1;
}
        format(strv, 64, "Zabranjeno vam je da govorite");
        SendClientMessage(ID,0x17E3DC, strv);
        Muted[ID] = 1;
        format(stri, 64, "%s je zabranjeno da govori", pName);
        SendClientMessageToAll(0x17E3DC, stri);
        printf("Admin %s je zabranio %s da govori", muteername, pName);
    }
    return 1;

    }
   
   
   
   
    if(strcmp(cmdtext, "/kick", true, 5))
{
    if(strlen(cmdtext[6]))
    {
        SendClientMessage(playerid,0x17E3DC , "Koristite: /kick [playerid] [razlog]");
        return 1;
    }
    new ID = strval(cmdtext[6]);
    new pName[24], kickername[24], stri[64], strv[256];
    tmp = strtok(cmdtext,idx);
    gMessage = strrest(cmdtext,idx);
    if(IsPlayerConnected(ID))
    {
         GetPlayerName(ID, pName, 24);
        GetPlayerName(playerid, kickername, 24);
            if(IsPlayerNPC(ID))
{
     SendClientMessage(playerid, 0x17E3DC, "Nemozes kickati NPC-a");
     return 1;
}
    if(ID == playerid)
{
     SendClientMessage(playerid, 0x17E3DC, "Nemozes kickati samog sebe");
     return 1;
}
     format(strv, 64, "%s kickani ste sa ovoga servera", gMessage);
        SendClientMessage(ID,0x17E3DC, strv);
        Kick(ID);
        format(stri, 64, "%s je kickan sa servera zbog %s", pName,gMessage);
        SendClientMessageToAll(0x17E3DC, stri);
        printf("Admin %s je kickao %s zbog %s", kickername, pName,gMessage);
    }
    return 1;

    }

    if (strcmp("/pravila", cmdtext, true, 10) == 0)
    {
        SendClientMessage(playerid, 0x17E3DC, "----------- PRAVILA --------------------- Extesna DeathMatch ----------");
        SendClientMessage(playerid, 0x17E3DC, " ");
        SendClientMessage(playerid, 0x17E3DC, " Zabranjeno je koristiti cheat ili neki hack u svoju ili tudju korist");
        SendClientMessage(playerid, 0x17E3DC, " Zabranjen je BUG ABUSING ili koristenje bugova koji daju korist");
        SendClientMessage(playerid, 0x17E3DC, " Zabranjeno je psovanje ili neko drugo vrijedajnje igraca");
        SendClientMessage(playerid, 0x17E3DC, " Zabranjen je SPAWN KILL ili ubijanje na mjestu stvaranja igraca");
        SendClientMessage(playerid, 0x17E3DC, " Obavezno slusati i postavati admine kao i druge igrace");
        SendClientMessage(playerid, 0x17E3DC, " ");
        SendClientMessage(playerid, 0x17E3DC, " ----- Admin Team: Go0[G]Le, JuustyGe ---------------------------------");

        return 1;
    }
   
    if (strcmp ("/webinfo", cmdtext, true, 10) == 0)
    {
       SendClientMessage(playerid, 0x17E3DC, "----------- WEB --------------------------- Extesna DeathMach ----------");
       SendClientMessage(playerid, 0x17E3DC, " ");
       SendClientMessage(playerid, 0x17E3DC, " Forum je u izradi");
       SendClientMessage(playerid, 0x17E3DC, " ");
       SendClientMessage(playerid, 0x17E3DC, "------------------------------------------------------------------------");
       
       return 1;
    }
   
    if (strcmp ("/komande", cmdtext, true, 10) == 0)
    {
       SendClientMessage(playerid, 0x17E3DC, "----------- KOMANDE ----------------------- Extesna DeathMach ----------");
       SendClientMessage(playerid, 0x17E3DC, " ");
       SendClientMessage(playerid, 0x17E3DC, " /pravila - lista pravila kaja se moraju postovati");
       SendClientMessage(playerid, 0x17E3DC, " /webinfo - web stranica nasega foruma");
       SendClientMessage(playerid, 0x17E3DC, " /komande - lista komandi koje mozete koristiti na serveru");
       SendClientMessage(playerid, 0x17E3DC, " ");
       SendClientMessage(playerid, 0x17E3DC, "------------------------------------------------------------------------");

       return 1;
    }
    if (strcmp ("/kill", cmdtext, true, 10) == 0)
    {
       SetPlayerHealth(playerid,0);

       return 1;
    }
    if (strcmp ("/ahelp", cmdtext, true, 10) == 0)
    {
       SendClientMessage(playerid, 0x17E3DC, "----------- ADMIN KOMANDE ----------------- Extesna DeathMach ----------");
       SendClientMessage(playerid, 0x17E3DC, " ");
       SendClientMessage(playerid, 0x17E3DC, "/ban - banati igraca");
       SendClientMessage(playerid, 0x17E3DC, "/kick - kickati igraca");
       SendClientMessage(playerid, 0x17E3DC, "/mute - zabraniti igracu da govori");
       SendClientMessage(playerid, 0x17E3DC, "/unmute - ukinuti zbranu igracu da govori");
       SendClientMessage(playerid, 0x17E3DC, "/freeze - zabraniti igracu da se mice");
       SendClientMessage(playerid, 0x17E3DC, "/unfreeze - ukinuti zabranu igracu da se mice");
       SendClientMessage(playerid, 0x17E3DC, "/createcash - stvoriti pare");
       SendClientMessage(playerid, 0x17E3DC, " ");
       SendClientMessage(playerid, 0x17E3DC, "------------------------------------------------------------------------");

       return 1;
    }
    if(strcmp(cmdtext, "/ban", true, 4))
{
    if(strlen(cmdtext[5]))
    {
        SendClientMessage(playerid, 0x17E3DC, "Koristite: /ban [playerid] [razlog]");
        return 1;
    }
    new ID = strval(cmdtext[5]);
    new pName[24], banername[24], stri[64], strv[256];
    tmp = strtok(cmdtext,idx);
    gMessage = strrest(cmdtext,idx);
    if(IsPlayerConnected(ID))
    {
        GetPlayerName(ID, pName, 24);
        GetPlayerName(playerid, banername, 24);
            if(IsPlayerNPC(ID))
{
     SendClientMessage(playerid, 0x17E3DC, "Nemozes banati NPC-a");
     return 1;
}
    if(ID == playerid)
{
     SendClientMessage(playerid, 0x17E3DC, "Nemozes banati samog sebe");
     return 1;
}
        format(strv, 64, " %s banan si sa ovoga servera", gMessage);
        SendClientMessage(ID,0x17E3DC, strv);
        Ban(ID);
        format(stri, 64, "%s je banan zbog %s", pName,gMessage);
        SendClientMessageToAll(0x17E3DC, stri);
        printf("Admin %s je banao %s zbog %s", banername, pName,gMessage);
    }
    return 1;
    }
   

    return SendClientMessage(playerid, 0xFFFFFF, "Nepostojeca komanda");
}