SA-MP Forums Archive
How to make this script to work only at location ? - 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: How to make this script to work only at location ? (/showthread.php?tid=458997)



How to make this script to work only at location ? - bustern - 19.08.2013

How to make this to work only at any location, that i want ?
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp("/repair", cmdtext))
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not in a vehicle!");
        RepairVehicle(GetPlayerVehicleID(playerid));
        SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle has been successfully repaired!");
        return 1;
    }
}
And how to make that, when a player repair his vehicle, he must pay 100


Re : How to make this script to work only at location ? - Garwan50 - 19.08.2013

pawn Код:
if(IsPlayerInRangeOfPoint(playerid, Float:range, Float:x, Float:y, Float:z))



Re: How to make this script to work only at location ? - sleepysnowflake - 19.08.2013

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp("/repair", cmdtext))
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not in a vehicle!");
        if(!IsPlayerInRangeOfPoint(...)) return  SendClientMessage(playerid, 0xFFFFFFFF, "You must be at the repair place to repair things! loln0blord");
        RepairVehicle(GetPlayerVehicleID(playerid));
        SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle has been successfully repaired!");
        return 1;
    }
}
how to use IsPlayerInRangeOfPoint


Re: How to make this script to work only at location ? - bustern - 19.08.2013

How to make to player must pay to repair his car ?


Re: How to make this script to work only at location ? - sleepysnowflake - 19.08.2013

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp("/repair", cmdtext))
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not in a vehicle!");
        if(!IsPlayerInRangeOfPoint(...)) return  SendClientMessage(playerid, 0xFFFFFFFF, "You must be at the repair place to repair things! loln0blord");
       if(GetPlayerMoney(playerid) <= 500) return  SendClientMessage(playerid, 0xFFFFFFFF, "You poor fuck, you can't afford this");
       RepairVehicle(GetPlayerVehicleID(playerid));
        SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle has been successfully repaired!");
       GivePlayerMoney(playerid, -500);
        return 1;
    }
}
anything more you desire my lord?


Re: How to make this script to work only at location ? - bustern - 19.08.2013

Thx you man !I have wast question, if you want-check this https://sampforum.blast.hk/showthread.php?tid=458999


Re: How to make this script to work only at location ? - sleepysnowflake - 19.08.2013

i believe it is wiser to make a 3D text there rather than checking his coordinates every second.


Re: How to make this script to work only at location ? - Isolated - 19.08.2013

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp("/repair", cmdtext))
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not in a vehicle!");
        if(!IsPlayerInRangeOfPoint(...)) return  SendClientMessage(playerid, 0xFFFFFFFF, "You must be at the repair place to repair things! loln0blord");
       if(GetPlayerMoney(playerid) <= 500) return  SendClientMessage(playerid, 0xFFFFFFFF, "You poor fuck, you can't afford this");
       RepairVehicle(GetPlayerVehicleID(playerid));
        SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle has been successfully repaired!");
       GivePlayerMoney(playerid, -500);
        return 1;
    }
}

This however, you'll want to check to ensure he even has 500$ to begin with:
pawn Код:
if(GetPlayerMoney(playerid) >= 500) {
    GivePlayerMoney(playerid, -500);
}
else { // messages }



Re: How to make this script to work only at location ? - sleepysnowflake - 19.08.2013

Quote:
Originally Posted by Isolated
Посмотреть сообщение
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp("/repair", cmdtext))
    {
        if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "You are not in a vehicle!");
        if(!IsPlayerInRangeOfPoint(...)) return  SendClientMessage(playerid, 0xFFFFFFFF, "You must be at the repair place to repair things! loln0blord");
       if(GetPlayerMoney(playerid) <= 500) return  SendClientMessage(playerid, 0xFFFFFFFF, "You poor fuck, you can't afford this");
       RepairVehicle(GetPlayerVehicleID(playerid));
        SendClientMessage(playerid, 0xFFFFFFFF, "Your vehicle has been successfully repaired!");
       GivePlayerMoney(playerid, -500);
        return 1;
    }
}

This however, you'll want to check to ensure he even has 500$ to begin with:
pawn Код:
if(GetPlayerMoney(playerid) >= 500) {
    GivePlayerMoney(playerid, -500);
}
else { // messages }
pardon me but i have done that already, maybe in a wrong way, correct me if i'm wrong but

pawn Код:
if(GetPlayerMoney(playerid) <= 500) return  SendClientMessage(playerid, 0xFFFFFFFF, "You poor fuck, you can't afford this");
this is same as this
pawn Код:
if(GetPlayerMoney(playerid) >= 500) {
    GivePlayerMoney(playerid, -500);
}



Re: How to make this script to work only at location ? - Isolated - 19.08.2013

Quote:
Originally Posted by Berlovan
Посмотреть сообщение
pardon me but i have done that already, maybe in a wrong way, correct me if i'm wrong but

pawn Код:
if(GetPlayerMoney(playerid) <= 500) return  SendClientMessage(playerid, 0xFFFFFFFF, "You poor fuck, you can't afford this");
this is same as this
pawn Код:
if(GetPlayerMoney(playerid) >= 500) {
    GivePlayerMoney(playerid, -500);
}
Right you are buddy, entirely my fault. I haven't slept yet and kind of skimmed over that. Sorry buddy.