SA-MP Forums Archive
string prob - 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)
+--- Thread: string prob (/showthread.php?tid=602998)



string prob - Shaheen - 16.03.2016

i had added multiple strings in one fs but giving errors

Код:
 new 
                string[64] 
            ; 
            FreezePlayer(playerid, 3000); 
            DisablePlayerCheckpoint(playerid); 
            GameTextForPlayer(playerid, "~g~Passengers UnLoading !", 2000, 4); 
		  
            SetPlayerScore(playerid, GetPlayerScore(playerid) + 1); 
            new string[128];
			  new RandomPay = random(50000 - 10000) + 10000;
			  GivePlayerMoney( playerid, RandomPay );
		     SendClientMessage(playerid, COLOR_RED,"-------------------------");
		    format(string, sizeof(string), "      You Have Got Paycheck Of => $%i", RandomPay); 
            GetPlayerName(playerid, string, MAX_PLAYER_NAME); 
            strcat(string, " Completed a Flight!"); 
            SendClientMessageToAll(COLOR_ORANGE, string); 
            SendClientMessage(playerid, COLOR_GREY, "All Passengers had Been UnBoarded!");  
            MissionStage[playerid] = STAGE_IDLE; 
        } 
        default: { // STAGE_LOAD
Errors;
symbol already defined "string"
symbol is assigned a value tht is never used


Re: string prob - itsCody - 16.03.2016

PHP код:
new string[64]
...
new 
string[128]; 
You have two of them defined with different lengths, remove one of them.


Re: string prob - XtremeRz - 16.03.2016

Actually, ye as @itsCody said, you defined the variable "string" twice. remove one of them. i suggest removing the "string[128]" one..

"symbol is assigned a value that is never used" isn't rly an error..


Re: string prob - saffierr - 16.03.2016

lol... The error its self says it all doesn't it..?


Re: string prob - Shaheen - 16.03.2016

Код:
public OnPlayerEnterCheckpoint(playerid) { 
    switch(MissionStage[playerid]) { 
        case STAGE_IDLE: {} // do not remove 
        case STAGE_UNLOAD: { 
            new 
                string[64] 
            ; 
            FreezePlayer(playerid, 3000); 
            DisablePlayerCheckpoint(playerid); 
            GameTextForPlayer(playerid, "~g~Passengers UnLoading !", 2000, 4); 
		  
            SetPlayerScore(playerid, GetPlayerScore(playerid) + 1); 
		  new RandomPay = random(5000 - 20000) + 5000;
		  GivePlayerMoney( playerid, RandomPay );
		  format(string, sizeof(string), " You Have Recieved $%i for Completing your Flight!", RandomPay);
            GetPlayerName(playerid, string, MAX_PLAYER_NAME); 
            strcat(string, " Completed a Flight!"); 
            SendClientMessageToAll(COLOR_ORANGE, string); 
            SendClientMessage(playerid, COLOR_GREY, "All Passengers had Been UnBoarded!");  
            MissionStage[playerid] = STAGE_IDLE; 
        } 
        default: { // STAGE_LOAD 
            new 
                rand = random(sizeof gAirports - 1) 
            ; 
            if(rand == (MissionStage[playerid] - STAGE_LOAD)) { 
                rand++; 
            } 
            FreezePlayer(playerid, 3000); 
            DisablePlayerCheckpoint(playerid); 
            GameTextForPlayer(playerid, "~g~Passengers Boarding !", 2000, 4); 
            SetPlayerCheckpoint(playerid, gAirports[rand][0], gAirports[rand][1], gAirports[rand][2], 10.0); 
            SendClientMessage(playerid, COLOR_GREY, "All Passengers has Been Boarded and Fastened Their Seat Belts!"); 

            MissionStage[playerid] = STAGE_UNLOAD; 
        } 
    } 
    return false; 
}
see in above script i have 2 string one about comepleted the flight and other about money got after completing but it does not work correclty ... whats wrong with it ?


Re: string prob - itsCody - 16.03.2016

Then rename them
new string[xx], string1[xx];


Re: string prob - Shaheen - 16.03.2016

remove plz !


Re: string prob - Shaheen - 17.03.2016

Quote:
Originally Posted by itsCody
Посмотреть сообщение
Then rename them
new string[xx], string1[xx];
can u give an example ?


Re: string prob - itsCody - 17.03.2016

Just put it after OnPlayerEnterCheckpoint and use the same thing for formatting all strings
PHP код:
public OnPlayerEnterCheckpoint(playerid) {
    new 
string[128]; 



Re: string prob - Shaheen - 17.03.2016

Quote:
Originally Posted by itsCody
Посмотреть сообщение
Just put it after OnPlayerEnterCheckpoint and use the same thing for formatting all strings
PHP код:
public OnPlayerEnterCheckpoint(playerid) {
    new 
string[128]; 
i had done that but it doesnot show client message that "how much money i earned from that flight ! "
here is the code

PHP код:
public OnPlayerEnterCheckpoint(playerid) { 
new 
string[128];
    switch(
MissionStage[playerid]) { 
        case 
STAGE_IDLE: {} // do not remove 
        
case STAGE_UNLOAD: {
            
FreezePlayer(playerid3000); 
            
DisablePlayerCheckpoint(playerid); 
            
GameTextForPlayer(playerid"~g~Passengers UnLoading !"20004); 
          
            
SetPlayerScore(playeridGetPlayerScore(playerid) + 1); 
             new 
RandomPay random(10000) + 5000;
            
GivePlayerMoneyplayeridRandomPay );
            
format(stringsizeof(string), " You Have Recieved $%i for Completing your Flight!"RandomPay);
            
GetPlayerName(playeridstringMAX_PLAYER_NAME); 
            
strcat(string" Completed a Flight!"); 
            
SendClientMessageToAll(COLOR_ORANGEstring); 
            
SendClientMessage(playeridCOLOR_GREY"All Passengers had Been UnBoarded!");  
            
MissionStage[playerid] = STAGE_IDLE
        } 
        default: { 
// STAGE_LOAD 
            
new 
                
rand random(sizeof gAirports 1
            ; 
            if(
rand == (MissionStage[playerid] - STAGE_LOAD)) { 
                
rand++; 
            } 
            
FreezePlayer(playerid3000); 
            
DisablePlayerCheckpoint(playerid); 
            
GameTextForPlayer(playerid"~g~Passengers Boarding !"20004); 
            
SetPlayerCheckpoint(playeridgAirports[rand][0], gAirports[rand][1], gAirports[rand][2], 10.0); 
            
SendClientMessage(playeridCOLOR_GREY"All Passengers has Been Boarded and Fastened Their Seat Belts!"); 
            
MissionStage[playerid] = STAGE_UNLOAD
        } 
    } 
    return 
false