2 Problems and 1 Question
#1

I was bored, so I decided to try to solve some little problems I have in my scripts... but I didn't succeed...


[SIZE="1"]Problem 1:


SOLVED

Problem 2

SOLVED


1 Question:

How can I set a player colour, and when he login he will get the colour that he choose? cuz I want a player to choose their colour, and when he login he will get his chosen colour : )


lol, this is alot xD
I would love it if som1 could help me!
Reply
#2

Loose intendation is caused by the location of your code. For some reason pawn is very sensitive at this.
pawn Код:
#include <a_samp>
#include <sscanf2>


public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print("Colour System");
    print("--------------------------------------\n");
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
      if(strcmp("/color", cmdtext, true, 6) == 0)
      {
              new _red, _green, _blue;
              if(sscanf(cmdtext[6], "iii", _red, _green, _blue)) {
                   SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /color <red> <green> <blue> (0 - 255)");
                   return 1;
              }
              if((255 < _red < 0) || (255 < _green < 0) || (255 < _blue < 0)) {
                   SendClientMessage(playerid, 0xFFFFFFAA, "ERROR: Only from 0 till 255!");
                   return 1;
              }
              new string[32];
              _blue = ((_red << 16) | (_green << 8) | _blue);
              format(string, sizeof string, "Color changed to {%06x}%06x", _blue, _blue);
              SendClientMessage(playerid, 0xFFFFFFAA, string);
              SetPlayerColor(playerid, ((_blue << 8) | 0xFF));
              return 1;
    }
    return 0;    //Line 33
}
That should work just fine.

The other error says you already have defined strtok, maybe you pasted it twice?
Reply
#3

Quote:
Originally Posted by hanzen
Посмотреть сообщение
Loose intendation is caused by the location of your code. For some reason pawn is very sensitive at this.
pawn Код:
#include <a_samp>
#include <sscanf2>


public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print("Colour System");
    print("--------------------------------------\n");
    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
      if(strcmp("/color", cmdtext, true, 6) == 0)
      {
              new _red, _green, _blue;
              if(sscanf(cmdtext[6], "iii", _red, _green, _blue)) {
                   SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /color <red> <green> <blue> (0 - 255)");
                   return 1;
              }
              if((255 < _red < 0) || (255 < _green < 0) || (255 < _blue < 0)) {
                   SendClientMessage(playerid, 0xFFFFFFAA, "ERROR: Only from 0 till 255!");
                   return 1;
              }
              new string[32];
              _blue = ((_red << 16) | (_green << 8) | _blue);
              format(string, sizeof string, "Color changed to {%06x}%06x", _blue, _blue);
              SendClientMessage(playerid, 0xFFFFFFAA, string);
              SetPlayerColor(playerid, ((_blue << 8) | 0xFF));
              return 1;
    }
    return 0;    //Line 33
}
That should work just fine.

The other error says you already have defined strtok, maybe you pasted it twice?
thanks for the help! even-tough I didn't see what you changed... anyways it works

about number 2, I don't know I didn't make that part of the GM...
Reply
#4

Dutils does include strtok too (1. error) but with a higher result string (2. error)

To solve this you need to put under #include <lethaldudb2>
pawn Код:
#include <lethaldudb2>
#define strtok strtok_ex
This doesnt change your code at all but it solves the errors

PS:
It looks like I cant write visitor messages in your profil :S
The code got already released in the ScriptRequestTopic so everyone can use it
It would be nice to mention who created it
Reply
#5

Quote:
Originally Posted by knackworst
Посмотреть сообщение
thanks for the help! even-tough I didn't see what you changed... anyways it works

about number 2, I don't know I didn't make that part of the GM...
He changed the position of return 0;, don't you know what does loose indentation means?

well this is an example

BAD indentation
pawn Код:
dcmd_mynickname(playerid,params[])
{
  new string[128];
      new pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
                  format(string, sizeof(string), "Your nickname is %s", pName);
         SendClientMessage(playerid, COLOR_YELLOW, string);
           return 1;
}
GOOD indentation
pawn Код:
dcmd_mynickname(playerid,params[])
{
    new string[128];
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    format(string, sizeof(string), "Your nickname is %s", pName);
    SendClientMessage(playerid, COLOR_YELLOW, string);
    return 1;
}
So that means your code isn't sorted well.
Reply
#6

Quote:
Originally Posted by Nero_3D
Посмотреть сообщение
Dutils does include strtok too (1. error) but with a higher result string (2. error)

To solve this you need to put under #include <lethaldudb2>
pawn Код:
#include <lethaldudb2>
#define strtok strtok_ex
This doesnt change your code at all but it solves the errors

PS:
It looks like I cant write visitor messages in your profil :S
The code got already released in the ScriptRequestTopic so everyone can use it
It would be nice to mention who created it
ok, thanks but look
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{

    dcmd(throw, 5, cmdtext);
   
      if(strcmp("/heal", cmdtext, true) == 0)  //heal command
    {
      if (IsPlayerAdminLevel(playerid, >4)) //Error line
       {
        SetPlayerHealth(playerid,100);
        SendClientMessage(playerid, 0xFF8000FF, "You succesfully healed yourself!");
       }
       return 1;
       }
Код:
C:\Users\William\Downloads\Ti+Stuntacular\gamemodes\Tropical_Island2.pwn(642) : error 017: undefined symbol "IsPlayerAdminLevel"
C:\Users\William\Downloads\Ti+Stuntacular\gamemodes\Tropical_Island2.pwn(642) : warning 215: expression has no effect
C:\Users\William\Downloads\Ti+Stuntacular\gamemodes\Tropical_Island2.pwn(642) : error 001: expected token: ";", but found ")"
C:\Users\William\Downloads\Ti+Stuntacular\gamemodes\Tropical_Island2.pwn(642) : error 029: invalid expression, assumed zero
C:\Users\William\Downloads\Ti+Stuntacular\gamemodes\Tropical_Island2.pwn(642) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
and yes I added the include and the define...

and I'm very sorry that you can't post message, I don't know why but somehow my settings keep changing

anyways, I think it's a very useful script and I think more people will see it in a topic then in useful functions...
but it's your choise : )
Reply
#7

Oh I downloaded an old version of LAdmin :S

just change the two lines from before to
pawn Код:
#include <IsPlayerLAdmin>
#define strtok strtok_ex
And that is not valid
pawn Код:
if (IsPlayerAdminLevel(playerid, >4))
it should be and yes it returns true if you got a higher Level
pawn Код:
if (IsPlayerAdminLevel(playerid, 4))
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)