;'Urban Race' event script

If GetUserFlag(0,11)<>0
	If GetUserFlag(0,11)=4
		SendMessageToUser(#USERID,"Sorry, you didn't win this time.", #MSG_TELL)
	Endif
	If GetUserFlag(0,11)=3
		SetUserFlag(0,11,4)
		SendMessageToAll(GetUserName(#USERID)+" has gotten 3rd place in the Urban Race!", #MSG_SERVER)
		If GetUserFlag(1,10) = 0
			SendMessageToUser(#USERID,"You recieve 5,000 silver.", #MSG_TELL)
			SetUserSilver(#USERID,GetUserSilver(#USERID)+5000)
		EndIf
	Endif
	If GetUserFlag(0,11)=2
		SetUserFlag(0,11,3)
		SendMessageToAll(GetUserName(#USERID)+" has gotten 2nd place in the Urban Race!", #MSG_SERVER)
		If GetUserFlag(1,10) = 0
			SendMessageToUser(#USERID,"You recieve 10,000 silver.", #MSG_TELL)
			SetUserSilver(#USERID,GetUserSilver(#USERID)+10000)
		EndIf
	Endif
	If GetUserFlag(0,11)=1
		SetUserFlag(0,11,2)
		SendMessageToAll("Congratulations! "+GetUserName(#USERID)+" has won the Urban Race!", #MSG_SERVER)
		If GetUserFlag(1,10) = 0
			SendMessageToUser(#USERID,"You recieve 20,000 silver.", #MSG_TELL)
			SetUserSilver(#USERID,GetUserSilver(#USERID)+20000)
			Timer(346,100,#USERID,0,0)
		EndIf
	Endif
	SetUserFlag(0,10,0)
	WarpUser(#USERID,509,10,11)
Else
	SetUserFlag(0,11,1)
	SendMessageToMap(#PARAM1,"Be the first one to the end to retrieve the reward! GO!", #MSG_EMOTE)
	OpenDoor(580,7,12)
	OpenDoor(580,8,12)
	OpenDoor(580,13,12)
	OpenDoor(580,14,12)
Endif

Label END

Continue = 1