SA-MP Forums Archive
Sorry for the question, but - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Sorry for the question, but (/showthread.php?tid=83265)



Sorry for the question, but - zallomallo - 24.06.2009

ELoc[playerid][0] = text[0];

Why is that only grabbing the first letter?


Re: Sorry for the question, but - Grim_ - 24.06.2009

Can you show the whole OnPlayerText callback?


Re: Sorry for the question, but - zallomallo - 24.06.2009

Wow, lol ok.
pawn Код:
public OnPlayerText(playerid, text[])
{
   
    new pname[24];
    new string[256];
    GetPlayerName(playerid, pname, sizeof(pname));
    format(string, sizeof(string), "%s says: %s", pname, text);
    if(PlayerData[OnCall][playerid] == 911) {
    format(string, sizeof(string), "%s says(Phone): %s", pname, text);
    ProxDetector(20.0,playerid,string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
    if(EStage[playerid] == 1) {
    if(strcmp("police", text, true)) {
    SendClientMessage(playerid, White, "Please specify your location.");
    EStage[playerid] = 2;
    return 0;
    }
    if(strcmp("paramedic", text, true)) {
    SendClientMessage(playerid, White, "Please specify your location.");
    EStage[playerid] = 4;
    return 0;
    }
    if(strcmp("both", text, true)) {
    SendClientMessage(playerid, White, "Please specify your location.");
    EStage[playerid] = 6;
    return 0;
    }
    else {
    SendClientMessage(playerid, White, "I'm sorry, I do not understand that.");
    return 0;
    }
    }
   
    if(EStage[playerid] == 6) {
    ELoc[playerid][0] = text[0];
    SendClientMessage(playerid, White, "Please explain your situation.");
    EStage[playerid] = 7;
    return 0;
    }
    if(EStage[playerid] == 8) {
    ESit[playerid][0] = text[0];
    SendClientMessage(playerid, White, "Ok, sit tight, they have been notified.");
    for(new i; i < MAX_PLAYERS; i ++) {
    if(PlayerData[RChannel][i] == 912 || PlayerData[RChannel][i] == 913) {
    SendClientMessage(playerid, White, "Auto Dispatch: We have an emergency call.");
    format(string, sizeof(string), "Location: %s", ELoc[playerid]);
    SendClientMessage(playerid, White, string);
    format(string, sizeof(string), "Situation: %s", ESit[playerid]);
    SendClientMessage(playerid, White, string);
    }
    }
    return 0;
    }

   
    if(EStage[playerid] == 4) {
    ELoc[playerid][0] = text[0];
    SendClientMessage(playerid, White, "Please explain your situation.");
    EStage[playerid] = 3;
    return 0;
    }
    if(EStage[playerid] == 5) {
    ESit[playerid][0] = text[0];
    SendClientMessage(playerid, White, "Ok, sit tight, Paramedics have been notified.");
    for(new i; i < MAX_PLAYERS; i ++) {
    if(PlayerData[RChannel][i] == 913) {
    SendClientMessage(playerid, White, "Auto Dispatch: We have an emergency call.");
    format(string, sizeof(string), "Location: %s", ELoc[playerid]);
    SendClientMessage(playerid, White, string);
    format(string, sizeof(string), "Situation: %s", ESit[playerid]);
    SendClientMessage(playerid, White, string);
    }
    }
    return 0;
    }


   
   
    if(EStage[playerid] == 2) {
    ELoc[playerid][0] = text[0];
    SendClientMessage(playerid, White, "Please explain your situation.");
    EStage[playerid] = 3;
    return 0;
    }
    if(EStage[playerid] == 3) {
    ESit[playerid][0] = text[0];
    SendClientMessage(playerid, White, "Ok, sit tight, Police have been notified.");
    for(new i; i < MAX_PLAYERS; i ++) {
    if(PlayerData[RChannel][i] == 912) {
    SendClientMessage(playerid, White, "Auto Dispatch: We have an emergency call.");
    format(string, sizeof(string), "Location: %s", ELoc[playerid]);
    SendClientMessage(playerid, White, string);
    format(string, sizeof(string), "Situation: %s", ESit[playerid]);
    SendClientMessage(playerid, White, string);
    }
    }
    }
    return 0;
    }


    if(PlayerData[OnCall][playerid] != -1 && PlayerData[PickedUp][PlayerData[OnCall][playerid]]) {
    SendClientMessage(PlayerData[OnCall][playerid], Yellow1, string);
    format(string, sizeof(string), "%s says(Phone): %s", pname, text);
    ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
    return 0;
    }
    ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
    return 0;
}



Re: Sorry for the question, but - yom - 24.06.2009

Quote:
Originally Posted by zallomallo
ELoc[playerid][0] = text[0];

Why is that only grabbing the first letter?
Because 'text[0]' is the first cell of 'text', and each character in a string use one cell.


Re: Sorry for the question, but - zallomallo - 24.06.2009

I know that, but when I removed [ 0] from text I get: error 006: must be assigned to an array


Re: Sorry for the question, but - abhinavdabral - 24.06.2009

Do not use [] ...........

ELoc[playerid] = text;


Thank You
Abhinav


Re: Sorry for the question, but - zallomallo - 24.06.2009

Then I get error 047: array sizes do not match, or destination array is too small.

My declaration

new ELoc[MAX_PLAYERS][257];
new ESit[MAX_PLAYERS][257];


Re: Sorry for the question, but - abhinavdabral - 24.06.2009

so code for that declaration is
Код:
ELoc[playerid]=ESit[playerid];
Or If you want to Put the data from ELoc to text then it would be :
Код:
ELoc[playerid]=text;
It was working on mine, now you test it...
Tell me if still no success...i would be greatful to help.

TIP: I recommend you to put sizes like 256, 512 or 128 coz 257 figure looks ...looks like ....SHIT ..lol...no offence ...

Thank You
Abhinav


Re: Sorry for the question, but - zallomallo - 24.06.2009

It still says: error 047: array sizes do not match, or destination array is too small. Thanks for the help, btw.


Re: Sorry for the question, but - abhinavdabral - 25.06.2009

I don't know what is happening at your side, but i tried the same code , and it was working. If your code is personal and confidential, PM me.

Thank You
Abhinav