Gamemode Problem
#1

I got a serious problem yesterday with the gamemode. I change the messages on the /goto command and when I went to test it in every command appears text "You have teleported to Harry_Potter" (Bot id 0) and I was teleported to the bot. I delete the /goto command and the that problem still was at /carcolor command. I remove /carcolor command too and all works fine. But I want two these commands.Here is OnPlayerCommandText
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new cmd[256], tmp[256], idx;
    if(strcmp(cmd, "/carcolor", true) == 0)
    {
        new color1, color2;
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid, -1, "USAGE: /carcolor [color1] [color2]");
        color1 = strval(tmp);
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp)) return SendClientMessage(playerid, -1, "USAGE: /carcolor [color1] [color2]");
        color2 = strval(tmp);
        ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
        return 1;
    }
    if (strcmp(cmdtext, "/tgoto", true, 10) == 0) {
        ShowPlayerDialog(playerid, 15, DIALOG_STYLE_LIST, "{FFFFFF}Toggle Goto", "{00FF00}Enable\n{FF0000}Disable", "Select", "Cancel");
        return 1;
    }
    if (strcmp("/infernus", cmdtext, true, 10) == 0) {
        new vehicleid;
        new Float:X,Float:Y,Float:Z,Float:Angle;
        GetPlayerPos(playerid,X,Y,Z);
        GetPlayerFacingAngle(playerid,Angle);
        GetPlayerVehicleID(playerid);
        vehicleid = vehicleid = CreateVehicle(411,X,Y,Z,Angle,-1,-1,600);
        PutPlayerInVehicle(playerid, vehicleid, 0);
        return 1;
    }
//More cars
    if(!strcmp(cmdtext,"/SavePOS", true)) {
        GetPlayerPos(playerid, X_P[playerid],Y_P[playerid],Z_P[playerid]);
        return true;
    }

    if(!strcmp(cmdtext,"/LoadPOS", true)) {
        if (GetPlayerState(playerid)==PLAYER_STATE_DRIVER)SetVehiclePos(GetPlayerVehicleID(playerid), X_P[playerid],Y_P[playerid],Z_P[playerid]);
        else SetPlayerPos(playerid, X_P[playerid],Y_P[playerid],Z_P[playerid]);
        ResetPlayerWeapons(playerid);
        return true;
    }
    if (strcmp(cmdtext, "/changeskin", true, 11) == 0) {
        new string[128], skinid;
        if(!cmdtext[11]) return SendClientMessage(playerid, 0x33AA33AA, "Usage: /changeskin [skinid]");
        skinid = strval(cmdtext[12]);
        switch(skinid) {
            case 3, 4, 5, 6, 8, 42, 65, 74, 86, 119, 149, 208, 268, 273, 289: { return SendClientMessage(playerid, 0x33AA33AA, "Error: invalid skin ID!"); }
            default:
            {
                SetPlayerSkin(playerid, skinid);
                format(string, sizeof(string), "You have successfully changed your skin to %d", skinid);
                SendClientMessage(playerid, 0x33AA33AA, string);
            }
        }
        return 1;
    }
    if (strcmp(cmdtext, "/ammu1", true) == 0) {
        RemovePlayerFromVehicle(playerid);
        SetPlayerPos(playerid,2336.6277,61.5870,25.9851);
        GameTextForPlayer(playerid,"",4000,6);
        return 1;
    }
//More Teleports
    if (strcmp(cmdtext, "/neon", true)==0) {
        ShowPlayerDialog(playerid, 8899, DIALOG_STYLE_LIST, "Pick Neon Color", "Blue\nRed\nGreen\nWhite\nPink\nYellow\nRemove All Neon", "Select", "Cancel");
        return 1;
    }
    else return SendClientMessage(playerid, COLOR_RED, "ERROR: Unknown command. See all the commands with /cmds");
}
This is only with /carcolor. Any command I wrote it says "USAGE: /carcolor [color1] [color2]"
And the stock
pawn Код:
// Written by DracoBlue.
stock strtok(const string[], &index,seperator=' ')
{
    new length = strlen(string);
    new offset = index;
    new result[MAX_STRING];
    while ((index < length) && (string[index] != seperator) && ((index - offset) < (sizeof(result) - 1)))
    {
        result[index - offset] = string[index];
        index++;
    }

    result[index - offset] = EOS;
    if ((index < length) && (string[index] == seperator))
    {
        index++;
    }
    return result;
}
Please help me
Reply
#2

Hello i am not good at scripting, but try to find this in your game mode, and paste the code here : "You have teleported to %s" , withouth "
Reply
#3

I said Here is OnPlayerCommandText, This is only with /carcolor. I remove the /goto command, but the same happens with carcolor. Every command --> "USAGE: /carcolor [color1] [color2]"
Reply
#4

looks like an array error, check if you're not going out of bounds anywhere
(example new array[10] -> for (new i = 0; i<=10, i++) {array[i] = 0} -> result array[10] is set to 0, array 10 doesn't exist as only 10 objects are created (array[0] - array[9])
this causes serious problems because you'll never know where it is writing 0 to)
Reply
#5

Can you explain me what do you mean?
At new, I have only this with [number]
pawn Код:
new Float:PlayerRandomSpawn[9][4] =               // 9 Spawns with 4 co-ords each (X,Y,Z,Angle)
{
    {1684.5787,1447.7128,10.7706,269.6873},
    {2048.1475,-2449.0293,17.2250,90.1532},
    {-1343.6301,-248.0083,14.1484},
    {365.3526,2537.0442,16.6648,181.8541},
    {-2763.3979,375.4521,5.6744,269.9205},
    {-1343.6301,-248.0083,14.1484},
    {2191.5481,1676.9471,11.6265,89.3353},
    {2048.1475,-2449.0293,17.2250,90.1532},
    {1684.5787,1447.7128,10.7706,269.6873}
};
But I had this weeks ago.
Reply
#6

it is just that if you write to a position in an array that haven't been declared at such (for example declaring array[2], but write to array[3000]) your compiler will give you an error, but if you do something like array[i] = 0; and i is 3000, it won't give you an error because the compiler can not know what "i" might be and therefore it WILL write 0 at array[3000]... you don't know what you are overwriting and it is causeing the most wired problems or crash your game/server
Reply
#7

But why this happened, I only added Random Messages by FireCat, and change the SendClientMessage on the /goto
It's now difficult, to fix it. I think I have [] at string/cmd/pName.
Reply
#8

nevermind it was just a guess
Reply
#9

I removed /goto and /carcolor and I put them on a FS.
It's works, but when I put it on gamemode it's bugged. Anyway thanks for replies/help!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)