If player is 3 seconds in pickup?
#1

Heey guys,
How can i make if a player is 3 seconds in a pickup there something happens?

Thanks admigo
Reply
#2

PHP код:
forward message();
 
public 
OnGameModeInit()
{
    print(
"Starting timer...");
    
SetTimer("message"3000false); // Set a timer of 3000 miliseconds (3 seconds)
}
 
public 
message()
{
    print(
"3 Seconds have passed, you must die.");

Tell me what you want to happen, and i'll make it for you :P
Reply
#3

Use the timer, then IsPlayerInRangeOfPoint to check if a player is in the pickup.
Reply
#4

I know i need to make a timer but how i can do this?
Reply
#5

Uhm..
PHP код:
new ttttimer;
forward xd();
public 
OnGameModeInit(){
ttttimer SetTimer("xd",ms to check,true);
}
public 
xd(){
for(new 
i=0,j=GetMaxPlayers();i<j;i++)
{
if(
IsPlayerInRangeOfPoint(irangexyz))
{
// what i do?
}
}

You can kill timer when gamemode end
KillTimer(ttttimer);
It's a simple example
Read:
https://sampwiki.blast.hk/wiki/IsPlayerInRangeOfPoint
https://sampwiki.blast.hk/wiki/SetTimer
Reply
#6

PHP код:
public OnGameModeInit() 

    print(
"Starting timer..."); 
    
SetTimer("message"3000false); // Set a timer of 3000 miliseconds (3 seconds) 
    
if(IsPlayerInRangeOfPoint(playeridFloat:rangeFloat:xFloat:yFloat:z))
    {
        
SendClientMessage(playerid,0xFFFFFFFF,"Type Your Message Here.");
    }

Reply
#7

pawn Код:
#include a_samp
forward pickuptimer();
public OnGameModeInit()
{

pickuptimer = SetTimer("pickuptimer", 3000, false);
return 1;
}

public pickuptimer()
{
if(IsPlayerInRangeOfPoint(playerid, Float:range, Float:x, Float:y, Float:z))
{
SetPlayerPos(playerid; x,y,z);
}
return 1;
}
Reply
#8

He wants that to happen when he stands in pickup for three seconds, why do you all give him OnGameModeInit?
Try this;
pawn Код:
new
    Float:PC1[MAX_PLAYERS][3],
    pickup;

public OnGameModeInit()
{
    pickup = CreatePickup(1242, 2, 1503.3359, 1432.3585, 10.1191, -1);
    return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == pickup) {
        GetPlayerPos(playerid, PC1[playerid][0], PC1[playerid][1], PC1[playerid][2]);
        SetTimerEx("IsNearPickup", 3000, false, "i", playerid);
    }
    return 1;
}

forward IsNearPickup();
public IsNearPickup() {
    if(IsPlayerInRangeOfPoint(playerid, 1.0, PC1[playerid][0], PC1[playerid][1], PC1[playerid][2])) {
        GivePlayerCash(playerid, 50000);
        SendClientMessage(playerid, -1, "You have been stood in pickup for three seconds.");
    }
}
EDIT: Had a mistake.
Reply
#9

Uhm you can use your code but if you know x,y,z why use GetPlayerPos then vars?
Use 1503.3359, 1432.3585, 10.1191 on IsPlayerInRangeOfPoint no?
Reply
#10

I edited it, watch it now.
It should work perfectly.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)