Hello and Merry Christmas to all the team members and the forum. Today I bring you a cmd to buy a phone and talk, saved in your system registry.
Well this is the '/ c buycell' :
[pawn]else if ( strcmp( cmd, "buycell", true ) == 0 )
{
new cash = GetPlayerMoney(playerid);
if (GetPlayerCel(playerid) == 1) {
SendClientMessage(playerid, GREEN,"You already have a telefono.Solo use it /c cell.");
}
if (GetPlayerCel(playerid) == 0) {
if ( !IsLoggedIn( playerid ) ) SendClientMessage( playerid, COLOR_RED, "Please login to your account!" );
else if(cash < 200) {
format( szMsg, sizeof( szMsg ), "Necesita
$%d) mas para comprar un telefono.",200 - cash);
SendClientMessage( playerid, COLOR_YELLOW, szMsg );
}
else if (!PlayerIsArea(6, playerid, 351.2946, 1110.8674, 25.3879)) SendClientMessage( playerid, COLOR_RED, "CountDown Head to the Mall!" );
else
{
IncPlayerCel(playerid,1);
SendClientMessage(playerid,COLOR_YELLOW,"You bought a Cellphone.Cost $200.Now use it with /c cell.");
DecPlayerHandCash(playerid,200);
}
}
return 1;
} [/pawn]
Now the '/c cell' :
[pawn]else if ( strcmp( cmd, "cell", true ) == 0 )
{
new plr;
tmp = strtok( cmdtext, idx ), plr = FindPlayerIDFromString( tmp );
if (GetPlayerCel(playerid) == 0) {
SendClientMessage(playerid, GREEN,"You do not have a phone. Buy it with /c buycell.");
}
if (GetPlayerCel(playerid) == 1) {
if ( !IsLoggedIn( playerid ) ) SendClientMessage( playerid, COLOR_RED, "Please login to your account!" );
else if ( !strlen( tmp ) ) SendClientMessage( playerid, COLOR_GREEN, "Type: /c cell [Nick/ID] [Message]" );
else if ( plr == INACTIVE_PLAYER_ID ) SendClientMessage( playerid, COLOR_RED, "Error: Unknown player." );
else
{
format( szMsg, sizeof( szMsg ), "Flames by cellphone to [%s] : (%s)", gPlayers[ plr ], cmdtext[strlen(tmp)+4]);
SendClientMessage( playerid, GREEN, szMsg );
format( szMsg, sizeof( szMsg ), "Calling you [%s] : (%s)", gPlayers[ playerid ], cmdtext[strlen(tmp)+4]);
SendClientMessage( plr, GREEN, szMsg );
}
}
return 1;
}[/pawn]
Those are the cmds, now we need to define a few things :
[pawn]new INFO[256];//This would be near the beginning of "gm"[/pawn]
[pawn]stock PlayerIsArea(Float:radi, playerid, Float:x, Float:y, Float:z)
{
if(IsPlayerConnected(playerid))
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
tempposx = (oldposx -x);
tempposy = (oldposy -y);
tempposz = (oldposz -z);
if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
return 1;
}
}
return 0;
}[/pawn]
[pawn]public GetPlayerCel(playerid)
{
format(INFO,256, USERS_FILE, gPlayers[playerid]);
new tel = dini_Int(INFO,"Cellphone");
return tel;
}[/pawn]
[pawn]public IncPlayerCel(playerid,amount)
{
format(INFO,256, USERS_FILE, gPlayers[playerid]);
dini_IntSet(INFO,"Cellphone", GetPlayerTel(playerid)+amount);
}[/pawn]
That's it. I hope you liked it and served .