Cellphone script doesent work.
#1

Hello,
I have a problem with my cellphone system. ID 0 can call ID 1, but 1 cannot call 0, otherwise you will receive the error "The given number isent found'
Here you see my code:
Код:
dcmd_call(playerid, params[]) {
	new number[5];
    if(sscanf(params, "s", number)) {
		SendClientMessage(playerid, COLOR_RED, "USAGE: /call [number]"); return 1;
	}
	if(pInfo[playerid][prepaid] < 2) {
	    SendClientMessage(playerid, COLOR_RED,"You don't have enough prepaid credits (2) to make a call!"); return 1;
	}
	new result = 0;
	GetPlayerName(playerid, pname, sizeof(pname));
 	for(new i; i<MAX_PLAYERS; i++)
	{
		if(strval(number) == pInfo[i][phonenum] && strval(number) != -1)
 		{
	            new iname[MAX_PLAYERS];
           	GetPlayerName(i, iname, sizeof(iname));
    		SetPVarInt(playerid, "receiverid", i);
    		SetPVarInt(i, "receiverid", playerid);
    		SetPlayerSpecialAction(playerid, SPECIAL_ACTION_USECELLPHONE);
    		format(str4, sizeof str4,"%s takes out a cellphone.",pname);
			SendMeMessage(playerid, str4);
			format(str, sizeof str,"You are calling %s... Connecting...",iname);
			SendClientMessage(playerid, COLOR_YELLOW, str);
			format(str2, sizeof str2,"Your cellphone starts to ring. Caller: %s. Use /p to pickup or /cancel to cancel.",pname);
			format(str3, sizeof str3,"%s's cellphone starts to ring.",iname);
			SendMeMessage(i, str3);
			called[i] = 1;
			SendClientMessage(i, COLOR_YELLOW, str2);
			SetTimerEx("Cellphonetimer",4000,1,"rid",i);
			result++;
		}
		if(result == 0)
		{
            GetPlayerName(playerid, pname, sizeof(pname));
			format(str4, sizeof str4,"%s takes out a cellphone.",pname);
			SendMeMessage(playerid, str4);
 			SendClientMessage(playerid, COLOR_GREY,"You receive a busy tone...");
 			SendClientMessage(playerid, COLOR_GREY,"The given number isen't found ...");
 			SetPlayerSpecialAction(playerid, SPECIAL_ACTION_STOPUSECELLPHONE);
			return 1;
		}
	}
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)